File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1013,7 +1013,7 @@ trait ErasedPtr: std::any::Any {
10131013
10141014impl < T > ErasedPtr for Ptr < T >
10151015where
1016- T : Clone + ByteRepr + ' static ,
1016+ T : ByteRepr + ' static ,
10171017 Ptr < T > : PartialEq ,
10181018{
10191019 fn pointee_type_id ( & self ) -> std:: any:: TypeId {
@@ -1024,35 +1024,13 @@ where
10241024 if self . pointee_type_id ( ) != src. pointee_type_id ( ) {
10251025 panic ! ( "memcpy: type mismatch" ) ;
10261026 }
1027-
10281027 let src_ptr = src
10291028 . as_any ( )
10301029 . downcast_ref :: < Ptr < T > > ( )
10311030 . expect ( "memcpy: downcast to Ptr<T> failed" ) ;
1032-
1033- let elem = std:: mem:: size_of :: < T > ( ) ;
1034-
1035- if len == elem {
1036- self . write ( src_ptr. read ( ) ) ;
1037- return ;
1038- }
1039-
1040- if elem != 0 && len. is_multiple_of ( elem) {
1041- let mut dst = self . clone ( ) ;
1042- let mut src_it = src_ptr. clone ( ) ;
1043- for _ in 0 ..( len / elem) {
1044- dst. write ( src_it. read ( ) ) ;
1045- dst += 1 ;
1046- src_it += 1 ;
1047- }
1048-
1049- return ;
1050- }
1051-
1052- panic ! (
1053- "memcpy: len {} not compatible with element size {}" ,
1054- len, elem
1055- ) ;
1031+ let dst_bytes: Ptr < u8 > = self . reinterpret_cast ( ) ;
1032+ let src_bytes: Ptr < u8 > = src_ptr. reinterpret_cast ( ) ;
1033+ dst_bytes. memcpy ( & src_bytes, len) ;
10561034 }
10571035
10581036 fn as_any ( & self ) -> & dyn std:: any:: Any {
You can’t perform that action at this time.
0 commit comments