@@ -2461,7 +2461,7 @@ impl<'a, T: ?Sized> From<NonNull<T>> for Unique<T> {
2461
2461
}
2462
2462
2463
2463
/// Previous name of `NonNull`.
2464
- #[ rustc_deprecated( since = "1.24 " , reason = "renamed to `NonNull`" ) ]
2464
+ #[ rustc_deprecated( since = "1.25.0 " , reason = "renamed to `NonNull`" ) ]
2465
2465
#[ unstable( feature = "shared" , issue = "27730" ) ]
2466
2466
pub type Shared < T > = NonNull < T > ;
2467
2467
@@ -2482,12 +2482,12 @@ pub type Shared<T> = NonNull<T>;
2482
2482
/// Usually this won't be necessary; covariance is correct for most safe abstractions,
2483
2483
/// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they
2484
2484
/// provide a public API that follows the normal shared XOR mutable rules of Rust.
2485
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2485
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2486
2486
pub struct NonNull < T : ?Sized > {
2487
2487
pointer : NonZero < * const T > ,
2488
2488
}
2489
2489
2490
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2490
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2491
2491
impl < T : ?Sized > fmt:: Debug for NonNull < T > {
2492
2492
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2493
2493
fmt:: Pointer :: fmt ( & self . as_ptr ( ) , f)
@@ -2496,20 +2496,20 @@ impl<T: ?Sized> fmt::Debug for NonNull<T> {
2496
2496
2497
2497
/// `NonNull` pointers are not `Send` because the data they reference may be aliased.
2498
2498
// NB: This impl is unnecessary, but should provide better error messages.
2499
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2499
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2500
2500
impl < T : ?Sized > !Send for NonNull < T > { }
2501
2501
2502
2502
/// `NonNull` pointers are not `Sync` because the data they reference may be aliased.
2503
2503
// NB: This impl is unnecessary, but should provide better error messages.
2504
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2504
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2505
2505
impl < T : ?Sized > !Sync for NonNull < T > { }
2506
2506
2507
2507
impl < T : Sized > NonNull < T > {
2508
2508
/// Creates a new `NonNull` that is dangling, but well-aligned.
2509
2509
///
2510
2510
/// This is useful for initializing types which lazily allocate, like
2511
2511
/// `Vec::new` does.
2512
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2512
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2513
2513
pub fn dangling ( ) -> Self {
2514
2514
unsafe {
2515
2515
let ptr = mem:: align_of :: < T > ( ) as * mut T ;
@@ -2524,19 +2524,19 @@ impl<T: ?Sized> NonNull<T> {
2524
2524
/// # Safety
2525
2525
///
2526
2526
/// `ptr` must be non-null.
2527
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2527
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2528
2528
pub const unsafe fn new_unchecked ( ptr : * mut T ) -> Self {
2529
2529
NonNull { pointer : NonZero :: new_unchecked ( ptr) }
2530
2530
}
2531
2531
2532
2532
/// Creates a new `NonNull` if `ptr` is non-null.
2533
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2533
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2534
2534
pub fn new ( ptr : * mut T ) -> Option < Self > {
2535
2535
NonZero :: new ( ptr as * const T ) . map ( |nz| NonNull { pointer : nz } )
2536
2536
}
2537
2537
2538
2538
/// Acquires the underlying `*mut` pointer.
2539
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2539
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2540
2540
pub fn as_ptr ( self ) -> * mut T {
2541
2541
self . pointer . get ( ) as * mut T
2542
2542
}
@@ -2546,7 +2546,7 @@ impl<T: ?Sized> NonNull<T> {
2546
2546
/// The resulting lifetime is bound to self so this behaves "as if"
2547
2547
/// it were actually an instance of T that is getting borrowed. If a longer
2548
2548
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
2549
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2549
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2550
2550
pub unsafe fn as_ref ( & self ) -> & T {
2551
2551
& * self . as_ptr ( )
2552
2552
}
@@ -2556,47 +2556,47 @@ impl<T: ?Sized> NonNull<T> {
2556
2556
/// The resulting lifetime is bound to self so this behaves "as if"
2557
2557
/// it were actually an instance of T that is getting borrowed. If a longer
2558
2558
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
2559
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2559
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2560
2560
pub unsafe fn as_mut ( & mut self ) -> & mut T {
2561
2561
& mut * self . as_ptr ( )
2562
2562
}
2563
2563
}
2564
2564
2565
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2565
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2566
2566
impl < T : ?Sized > Clone for NonNull < T > {
2567
2567
fn clone ( & self ) -> Self {
2568
2568
* self
2569
2569
}
2570
2570
}
2571
2571
2572
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2572
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2573
2573
impl < T : ?Sized > Copy for NonNull < T > { }
2574
2574
2575
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2575
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2576
2576
impl < T : ?Sized , U : ?Sized > CoerceUnsized < NonNull < U > > for NonNull < T > where T : Unsize < U > { }
2577
2577
2578
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2578
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2579
2579
impl < T : ?Sized > fmt:: Pointer for NonNull < T > {
2580
2580
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2581
2581
fmt:: Pointer :: fmt ( & self . as_ptr ( ) , f)
2582
2582
}
2583
2583
}
2584
2584
2585
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2585
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2586
2586
impl < T : ?Sized > From < Unique < T > > for NonNull < T > {
2587
2587
fn from ( unique : Unique < T > ) -> Self {
2588
2588
NonNull { pointer : unique. pointer }
2589
2589
}
2590
2590
}
2591
2591
2592
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2592
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2593
2593
impl < ' a , T : ?Sized > From < & ' a mut T > for NonNull < T > {
2594
2594
fn from ( reference : & ' a mut T ) -> Self {
2595
2595
NonNull { pointer : NonZero :: from ( reference) }
2596
2596
}
2597
2597
}
2598
2598
2599
- #[ stable( feature = "nonnull" , since = "1.24 .0" ) ]
2599
+ #[ stable( feature = "nonnull" , since = "1.25 .0" ) ]
2600
2600
impl < ' a , T : ?Sized > From < & ' a T > for NonNull < T > {
2601
2601
fn from ( reference : & ' a T ) -> Self {
2602
2602
NonNull { pointer : NonZero :: from ( reference) }
0 commit comments