diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libsyntax/ptr.rs | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
| download | rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip | |
Format the world
Diffstat (limited to 'src/libsyntax/ptr.rs')
| -rw-r--r-- | src/libsyntax/ptr.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index e75cc8b1756..4597624ef88 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -21,31 +21,30 @@ //! implementation changes (using a special thread-local heap, for example). //! Moreover, a switch to, e.g., `P<'a, T>` would be easy and mostly automated. -use std::fmt::{self, Display, Debug}; +use std::fmt::{self, Debug, Display}; use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; use std::{slice, vec}; -use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; /// An owned smart pointer. pub struct P<T: ?Sized> { - ptr: Box<T> + ptr: Box<T>, } /// Construct a `P<T>` from a `T` value. #[allow(non_snake_case)] pub fn P<T: 'static>(value: T) -> P<T> { - P { - ptr: box value - } + P { ptr: box value } } impl<T: 'static> P<T> { /// Move out of the pointer. /// Intended for chaining transformations not covered by `map`. - pub fn and_then<U, F>(self, f: F) -> U where + pub fn and_then<U, F>(self, f: F) -> U + where F: FnOnce(T) -> U, { f(*self.ptr) @@ -57,7 +56,8 @@ impl<T: 'static> P<T> { } /// Produce a new `P<T>` from `self` without reallocating. - pub fn map<F>(mut self, f: F) -> P<T> where + pub fn map<F>(mut self, f: F) -> P<T> + where F: FnOnce(T) -> T, { let x = f(*self.ptr); @@ -67,7 +67,8 @@ impl<T: 'static> P<T> { } /// Optionally produce a new `P<T>` from `self` without reallocating. - pub fn filter_map<F>(mut self, f: F) -> Option<P<T>> where + pub fn filter_map<F>(mut self, f: F) -> Option<P<T>> + where F: FnOnce(T) -> Option<T>, { *self.ptr = f(*self.ptr)?; @@ -174,7 +175,7 @@ impl<T> Into<Vec<T>> for P<[T]> { } impl<T> FromIterator<T> for P<[T]> { - fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> P<[T]> { + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> P<[T]> { P::from_vec(iter.into_iter().collect()) } } @@ -209,7 +210,8 @@ impl<T: Decodable> Decodable for P<[T]> { } impl<CTX, T> HashStable<CTX> for P<T> - where T: ?Sized + HashStable<CTX> +where + T: ?Sized + HashStable<CTX>, { fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); |
