diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-03-19 12:30:01 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-03-19 12:30:01 +0200 |
| commit | b29e299c180ca62403595b7b25f23545943d38b1 (patch) | |
| tree | 1086104c2bff6ab8f71d3585c1a31c29294cc0a6 /src/libstd | |
| parent | d5dceba8fae2a77ae652d348a4d757a6a52fe16c (diff) | |
| parent | 797d520d2baa6a9264060b657c3aeeed8c709167 (diff) | |
| download | rust-b29e299c180ca62403595b7b25f23545943d38b1.tar.gz rust-b29e299c180ca62403595b7b25f23545943d38b1.zip | |
Rollup merge of #32329 - sfackler:assert-recover-safe-pub, r=aturon
Make AssertRecoverSafe's field public It's basically the very definition of a newtype, so we might as well make things easy on people and let them construct and access it directly. r? @aturon
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/panic.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index aff11d036f8..f2789949887 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -161,7 +161,7 @@ pub trait RefRecoverSafe {} /// // }); /// /// // This, however, will compile due to the `AssertRecoverSafe` wrapper -/// let result = panic::recover(AssertRecoverSafe::new(|| { +/// let result = panic::recover(AssertRecoverSafe(|| { /// variable += 3; /// })); /// // ... @@ -185,7 +185,7 @@ pub trait RefRecoverSafe {} /// let other_capture = 3; /// /// let result = { -/// let mut wrapper = AssertRecoverSafe::new(&mut variable); +/// let mut wrapper = AssertRecoverSafe(&mut variable); /// panic::recover(move || { /// **wrapper += other_capture; /// }) @@ -193,7 +193,7 @@ pub trait RefRecoverSafe {} /// // ... /// ``` #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -pub struct AssertRecoverSafe<T>(T); +pub struct AssertRecoverSafe<T>(pub T); // Implementations of the `RecoverSafe` trait: // @@ -230,12 +230,16 @@ impl<T> RefRecoverSafe for AssertRecoverSafe<T> {} impl<T> AssertRecoverSafe<T> { /// Creates a new `AssertRecoverSafe` wrapper around the provided type. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] + #[rustc_deprecated(reason = "the type's field is now public, construct it directly", + since = "1.9.0")] pub fn new(t: T) -> AssertRecoverSafe<T> { AssertRecoverSafe(t) } /// Consumes the `AssertRecoverSafe`, returning the wrapped value. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] + #[rustc_deprecated(reason = "the type's field is now public, access it directly", + since = "1.9.0")] pub fn into_inner(self) -> T { self.0 } |
