@@ -76,15 +76,13 @@ impl<T: ?Sized> *const T { |
|
|
76 |
76 |
/// ```rust |
77 |
77 |
/// #![feature(pointer_try_cast_aligned)] |
78 |
78 |
/// |
79 |
|
- /// let aligned: *const u8 = 0x1000 as _; |
|
79 |
+ /// let x = 0u64; |
80 |
80 |
/// |
81 |
|
- /// // i32 has at most 4-byte alignment, so this will succeed |
82 |
|
- /// assert!(aligned.try_cast_aligned::().is_some()); |
|
81 |
+ /// let aligned: *const u64 = &x; |
|
82 |
+ /// let unaligned = unsafe { aligned.byte_add(1) }; |
83 |
83 |
/// |
84 |
|
- /// let unaligned: *const u8 = 0x1001 as _; |
85 |
|
- /// |
86 |
|
- /// // i32 has at least 2-byte alignment, so this will fail |
87 |
|
- /// assert!(unaligned.try_cast_aligned::().is_none()); |
|
84 |
+ /// assert!(aligned.try_cast_aligned::().is_some()); |
|
85 |
+ /// assert!(unaligned.try_cast_aligned::().is_none()); |
88 |
86 |
/// ``` |
89 |
87 |
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")] |
90 |
88 |
#[must_use = "this returns the result of the operation, \ |