File tree Expand file tree Collapse file tree 3 files changed +10
-19
lines changed Expand file tree Collapse file tree 3 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -381,10 +381,9 @@ fn remote_exception_to_error(exception: exception::Reader) -> Error {
381
381
}
382
382
_ => ( :: capnp:: ErrorKind :: Failed , "(malformed error)" . into ( ) ) ,
383
383
} ;
384
- let reason_str = match reason. to_str ( ) {
385
- Ok ( s) => s,
386
- Err ( _) => "<malformed utf-8 in error reason>" ,
387
- } ;
384
+ let reason_str = reason
385
+ . to_str ( )
386
+ . unwrap_or ( "<malformed utf-8 in error reason>" ) ;
388
387
Error {
389
388
extra : format ! ( "remote exception: {reason_str}" ) ,
390
389
kind,
@@ -570,9 +569,7 @@ impl<VatId> ConnectionState<VatId> {
570
569
}
571
570
}
572
571
} ) ;
573
- let maybe_fulfiller =
574
- mem:: replace ( & mut * self . disconnect_fulfiller . borrow_mut ( ) , None ) ;
575
- match maybe_fulfiller {
572
+ match self . disconnect_fulfiller . borrow_mut ( ) . take ( ) {
576
573
None => unreachable ! ( ) ,
577
574
Some ( fulfiller) => {
578
575
let _ = fulfiller. send ( Promise :: from_future ( promise. attach ( c) ) ) ;
Original file line number Diff line number Diff line change @@ -104,8 +104,7 @@ where
104
104
T : AsyncRead ,
105
105
{
106
106
fn drop ( & mut self ) {
107
- let maybe_fulfiller = :: std:: mem:: replace ( & mut self . on_disconnect_fulfiller , None ) ;
108
- match maybe_fulfiller {
107
+ match self . on_disconnect_fulfiller . take ( ) {
109
108
Some ( fulfiller) => {
110
109
let _ = fulfiller. send ( ( ) ) ;
111
110
}
@@ -162,7 +161,7 @@ where
162
161
) -> Promise < Option < Box < dyn crate :: IncomingMessage + ' static > > , :: capnp:: Error > {
163
162
let inner = self . inner . borrow_mut ( ) ;
164
163
165
- let maybe_input_stream = :: std :: mem :: replace ( & mut * inner. input_stream . borrow_mut ( ) , None ) ;
164
+ let maybe_input_stream = inner. input_stream . borrow_mut ( ) . take ( ) ;
166
165
let return_it_here = inner. input_stream . clone ( ) ;
167
166
match maybe_input_stream {
168
167
Some ( mut s) => {
@@ -279,8 +278,7 @@ where
279
278
}
280
279
281
280
fn accept ( & mut self ) -> Promise < Box < dyn crate :: Connection < VatId > > , :: capnp:: Error > {
282
- let connection = :: std:: mem:: replace ( & mut self . connection , None ) ;
283
- match connection {
281
+ match self . connection . take ( ) {
284
282
Some ( c) => Promise :: ok ( Box :: new ( c) as Box < dyn crate :: Connection < VatId > > ) ,
285
283
None => Promise :: from_future ( :: futures:: future:: pending ( ) ) ,
286
284
}
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ impl WirePointer {
159
159
}
160
160
161
161
#[ inline]
162
- pub fn target ( ptr : * const Self ) -> * const u8 {
162
+ pub unsafe fn target ( ptr : * const Self ) -> * const u8 {
163
163
let this_addr: * const u8 = ptr as * const _ ;
164
164
unsafe { this_addr. offset ( 8 * ( 1 + ( ( ( * ptr) . offset_and_kind . get ( ) as i32 ) >> 2 ) ) as isize ) }
165
165
}
@@ -2036,18 +2036,14 @@ mod wire_helpers {
2036
2036
// in the canonicalize=true case.
2037
2037
let whole_byte_size =
2038
2038
u64:: from ( value. element_count ) * u64:: from ( value. step ) / BITS_PER_BYTE as u64 ;
2039
- ptr:: copy_nonoverlapping (
2040
- value. ptr as * const u8 ,
2041
- ptr as * mut u8 ,
2042
- whole_byte_size as usize ,
2043
- ) ;
2039
+ ptr:: copy_nonoverlapping ( value. ptr , ptr, whole_byte_size as usize ) ;
2044
2040
let leftover_bits =
2045
2041
u64:: from ( value. element_count ) * u64:: from ( value. step ) % BITS_PER_BYTE as u64 ;
2046
2042
if leftover_bits > 0 {
2047
2043
let mask: u8 = ( 1 << leftover_bits as u8 ) - 1 ;
2048
2044
2049
2045
* ptr. offset ( whole_byte_size as isize ) =
2050
- mask & ( * ( value. ptr as * const u8 ) . offset ( whole_byte_size as isize ) )
2046
+ mask & ( * value. ptr . offset ( whole_byte_size as isize ) )
2051
2047
}
2052
2048
}
2053
2049
You can’t perform that action at this time.
0 commit comments