@@ -2218,7 +2218,7 @@ pub unsafe trait FromBytes: FromZeros {
2218
2218
/// trailing_dst: [()],
2219
2219
/// }
2220
2220
///
2221
- /// let _ = ZSTy::from_prefix_with_trailing_elements (b"UU", 0); // ⚠ Compile Error!
2221
+ /// let _ = ZSTy::ref_from_prefix_with_trailing_elements (b"UU", 0); // ⚠ Compile Error!
2222
2222
/// ```
2223
2223
///
2224
2224
/// # Examples
@@ -2240,7 +2240,7 @@ pub unsafe trait FromBytes: FromZeros {
2240
2240
/// // These are more bytes than are needed to encode two `Pixel`s.
2241
2241
/// let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];
2242
2242
///
2243
- /// let (pixels, rest) = Pixel::slice_from_prefix (bytes, 2).unwrap();
2243
+ /// let (pixels, rest) = <[ Pixel]>::ref_from_prefix_with_trailing_elements (bytes, 2).unwrap();
2244
2244
///
2245
2245
/// assert_eq!(pixels, &[
2246
2246
/// Pixel { r: 0, g: 1, b: 2, a: 3 },
@@ -2251,7 +2251,7 @@ pub unsafe trait FromBytes: FromZeros {
2251
2251
/// ```
2252
2252
#[ must_use = "has no side effects" ]
2253
2253
#[ inline]
2254
- fn from_prefix_with_trailing_elements (
2254
+ fn ref_from_prefix_with_trailing_elements (
2255
2255
bytes : & [ u8 ] ,
2256
2256
count : usize ,
2257
2257
) -> Result < ( & Self , & [ u8 ] ) , CastError < & [ u8 ] , Self > >
@@ -2274,7 +2274,7 @@ pub unsafe trait FromBytes: FromZeros {
2274
2274
where
2275
2275
Self : Sized + Immutable ,
2276
2276
{
2277
- <[ Self ] >:: from_prefix_with_trailing_elements ( bytes, count) . ok ( )
2277
+ <[ Self ] >:: ref_from_prefix_with_trailing_elements ( bytes, count) . ok ( )
2278
2278
}
2279
2279
2280
2280
/// Interprets the suffix of the given `bytes` as a `&[Self]` with length
@@ -2304,7 +2304,7 @@ pub unsafe trait FromBytes: FromZeros {
2304
2304
/// trailing_dst: [()],
2305
2305
/// }
2306
2306
///
2307
- /// let _ = ZSTy::from_suffix_with_trailing_elements (b"UU", 0); // ⚠ Compile Error!
2307
+ /// let _ = ZSTy::ref_from_suffix_with_trailing_elements (b"UU", 0); // ⚠ Compile Error!
2308
2308
/// ```
2309
2309
///
2310
2310
/// # Examples
@@ -2326,7 +2326,7 @@ pub unsafe trait FromBytes: FromZeros {
2326
2326
/// // These are more bytes than are needed to encode two `Pixel`s.
2327
2327
/// let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];
2328
2328
///
2329
- /// let (rest, pixels) = Pixel::slice_from_suffix (bytes, 2).unwrap();
2329
+ /// let (rest, pixels) = <[ Pixel]>::ref_from_suffix_with_trailing_elements (bytes, 2).unwrap();
2330
2330
///
2331
2331
/// assert_eq!(rest, &[0, 1]);
2332
2332
///
@@ -2337,7 +2337,7 @@ pub unsafe trait FromBytes: FromZeros {
2337
2337
/// ```
2338
2338
#[ must_use = "has no side effects" ]
2339
2339
#[ inline]
2340
- fn from_suffix_with_trailing_elements (
2340
+ fn ref_from_suffix_with_trailing_elements (
2341
2341
bytes : & [ u8 ] ,
2342
2342
count : usize ,
2343
2343
) -> Result < ( & [ u8 ] , & Self ) , CastError < & [ u8 ] , Self > >
@@ -2360,7 +2360,7 @@ pub unsafe trait FromBytes: FromZeros {
2360
2360
where
2361
2361
Self : Sized + Immutable ,
2362
2362
{
2363
- <[ Self ] >:: from_suffix_with_trailing_elements ( bytes, count) . ok ( )
2363
+ <[ Self ] >:: ref_from_suffix_with_trailing_elements ( bytes, count) . ok ( )
2364
2364
}
2365
2365
2366
2366
#[ deprecated( since = "0.8.0" , note = "`FromBytes::mut_from` now supports slices" ) ]
@@ -2459,11 +2459,11 @@ pub unsafe trait FromBytes: FromZeros {
2459
2459
#[ doc( hidden) ]
2460
2460
#[ must_use = "has no side effects" ]
2461
2461
#[ inline]
2462
- fn mut_slice_from_prefix ( bytes : & [ u8 ] , count : usize ) -> Option < ( & [ Self ] , & [ u8 ] ) >
2462
+ fn mut_slice_from_prefix ( bytes : & mut [ u8 ] , count : usize ) -> Option < ( & mut [ Self ] , & mut [ u8 ] ) >
2463
2463
where
2464
- Self : Sized + Immutable ,
2464
+ Self : Sized + IntoBytes + Immutable ,
2465
2465
{
2466
- <[ Self ] >:: from_prefix_with_trailing_elements ( bytes, count) . ok ( )
2466
+ <[ Self ] >:: mut_from_prefix_with_trailing_elements ( bytes, count) . ok ( )
2467
2467
}
2468
2468
2469
2469
/// Interprets the suffix of the given `bytes` as a `&mut [Self]` with length
@@ -2517,7 +2517,7 @@ pub unsafe trait FromBytes: FromZeros {
2517
2517
/// // These are more bytes than are needed to encode two `Pixel`s.
2518
2518
/// let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];
2519
2519
///
2520
- /// let (rest, pixels) = Pixel::mut_slice_from_suffix (bytes, 2).unwrap();
2520
+ /// let (rest, pixels) = <[ Pixel]>::mut_from_suffix_with_trailing_elements (bytes, 2).unwrap();
2521
2521
///
2522
2522
/// assert_eq!(rest, &[0, 1]);
2523
2523
///
0 commit comments