diff options
| author | bors <bors@rust-lang.org> | 2015-12-20 22:50:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-12-20 22:50:34 +0000 |
| commit | 3d150397a220d14e3236367587c6cdfdcaacab57 (patch) | |
| tree | a2049b59fdad021284431e4f5df4d2db8fdd8b37 /src/libsyntax | |
| parent | 19c997ea5e5e490e93021619c64df411f8f7c711 (diff) | |
| parent | e3da2a90033d233bf6d77e3c725880c12cfc8728 (diff) | |
| download | rust-3d150397a220d14e3236367587c6cdfdcaacab57.tar.gz rust-3d150397a220d14e3236367587c6cdfdcaacab57.zip | |
Auto merge of #30470 - petrochenkov:owned5, r=nrc
cc https://github.com/rust-lang/rust/pull/30095 r? @nrc
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ptr.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 1be0b08086d..0504c313c91 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -130,6 +130,10 @@ impl<T:fmt::Debug> fmt::Debug for P<[T]> { } impl<T> P<[T]> { + pub fn new() -> P<[T]> { + P::empty() + } + pub fn empty() -> P<[T]> { P { ptr: Default::default() } } @@ -177,12 +181,33 @@ impl<T: Clone> Clone for P<[T]> { } } +impl<T> From<Vec<T>> for P<[T]> { + fn from(v: Vec<T>) -> Self { + P::from_vec(v) + } +} + +impl<T> Into<Vec<T>> for P<[T]> { + fn into(self) -> Vec<T> { + self.into_vec() + } +} + impl<T> FromIterator<T> for P<[T]> { fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> P<[T]> { P::from_vec(iter.into_iter().collect()) } } +impl<T> IntoIterator for P<[T]> { + type Item = T; + type IntoIter = vec::IntoIter<T>; + + fn into_iter(self) -> Self::IntoIter { + self.into_vec().into_iter() + } +} + impl<'a, T> IntoIterator for &'a P<[T]> { type Item = &'a T; type IntoIter = slice::Iter<'a, T>; |
