@@ -1107,12 +1107,6 @@ mod tests {
1107
1107
& self ,
1108
1108
bytes : & ' bytes [ u8 ] ,
1109
1109
) -> Option < Option < & ' bytes T > > ;
1110
-
1111
- #[ allow( clippy:: needless_lifetimes) ]
1112
- fn test_try_from_mut < ' bytes > (
1113
- & self ,
1114
- bytes : & ' bytes mut [ u8 ] ,
1115
- ) -> Option < Option < & ' bytes mut T > > ;
1116
1110
}
1117
1111
1118
1112
impl < T : TryFromBytes + Immutable + KnownLayout + ?Sized > TestTryFromRef < T > for AutorefWrapper < T > {
@@ -1123,14 +1117,6 @@ mod tests {
1123
1117
) -> Option < Option < & ' bytes T > > {
1124
1118
Some ( T :: try_ref_from ( bytes) . ok ( ) )
1125
1119
}
1126
-
1127
- #[ allow( clippy:: needless_lifetimes) ]
1128
- fn test_try_from_mut < ' bytes > (
1129
- & self ,
1130
- bytes : & ' bytes mut [ u8 ] ,
1131
- ) -> Option < Option < & ' bytes mut T > > {
1132
- Some ( T :: try_mut_from ( bytes) . ok ( ) )
1133
- }
1134
1120
}
1135
1121
1136
1122
pub ( super ) trait TestTryReadFrom < T > {
@@ -1224,16 +1210,6 @@ mod tests {
1224
1210
None
1225
1211
}
1226
1212
1227
- #[ allow( clippy:: needless_lifetimes) ]
1228
- fn test_try_from_mut<' bytes>( & mut self , _bytes: & ' bytes mut [ u8 ] ) -> Option <Option <& ' bytes mut $ty>> {
1229
- assert_on_allowlist!(
1230
- test_try_from_mut( $ty) :
1231
- ManuallyDrop <[ UnsafeCell <bool >] >
1232
- ) ;
1233
-
1234
- None
1235
- }
1236
-
1237
1213
fn test_try_read_from( & mut self , _bytes: & [ u8 ] ) -> Option <Option <& $ty>> {
1238
1214
assert_on_allowlist!(
1239
1215
test_try_read_from( $ty) :
@@ -1342,10 +1318,8 @@ mod tests {
1342
1318
let bytes_mut = & mut vec. as_mut_slice( ) [ offset..offset+size] ;
1343
1319
bytes_mut. copy_from_slice( bytes) ;
1344
1320
1345
- let res = ww. test_try_from_mut( bytes_mut) ;
1346
- if let Some ( res) = res {
1347
- assert!( res. is_some( ) , "{}::try_mut_from({:?}): got `None`, expected `Some`" , stringify!( $ty) , val) ;
1348
- }
1321
+ let res = <$ty as TryFromBytes >:: try_mut_from( bytes_mut) ;
1322
+ assert!( res. is_ok( ) , "{}::try_mut_from({:?}): got `Err`, expected `Ok`" , stringify!( $ty) , val) ;
1349
1323
}
1350
1324
1351
1325
let res = bytes. and_then( |bytes| ww. test_try_read_from( bytes) ) ;
@@ -1365,10 +1339,8 @@ mod tests {
1365
1339
assert!( res. is_none( ) , "{}::try_ref_from({:?}): got Some, expected None" , stringify!( $ty) , c) ;
1366
1340
}
1367
1341
1368
- let res = w. test_try_from_mut( c) ;
1369
- if let Some ( res) = res {
1370
- assert!( res. is_none( ) , "{}::try_mut_from({:?}): got Some, expected None" , stringify!( $ty) , c) ;
1371
- }
1342
+ let res = <$ty as TryFromBytes >:: try_mut_from( c) ;
1343
+ assert!( res. is_err( ) , "{}::try_mut_from({:?}): got Ok, expected Err" , stringify!( $ty) , c) ;
1372
1344
1373
1345
let res = w. test_try_read_from( c) ;
1374
1346
if let Some ( res) = res {
0 commit comments