diff options
author | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
commit | a990de90fe41456a23e58bd087d2f107d321f3a1 (patch) | |
tree | 15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/proc-macro2/src/rcvec.rs | |
parent | 3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff) | |
download | fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip |
Deleted vendor folder
Diffstat (limited to 'vendor/proc-macro2/src/rcvec.rs')
-rw-r--r-- | vendor/proc-macro2/src/rcvec.rs | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/vendor/proc-macro2/src/rcvec.rs b/vendor/proc-macro2/src/rcvec.rs deleted file mode 100644 index 37955af..0000000 --- a/vendor/proc-macro2/src/rcvec.rs +++ /dev/null @@ -1,145 +0,0 @@ -use alloc::rc::Rc; -use alloc::vec; -use core::mem; -use core::panic::RefUnwindSafe; -use core::slice; - -pub(crate) struct RcVec<T> { - inner: Rc<Vec<T>>, -} - -pub(crate) struct RcVecBuilder<T> { - inner: Vec<T>, -} - -pub(crate) struct RcVecMut<'a, T> { - inner: &'a mut Vec<T>, -} - -#[derive(Clone)] -pub(crate) struct RcVecIntoIter<T> { - inner: vec::IntoIter<T>, -} - -impl<T> RcVec<T> { - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn iter(&self) -> slice::Iter<T> { - self.inner.iter() - } - - pub fn make_mut(&mut self) -> RcVecMut<T> - where - T: Clone, - { - RcVecMut { - inner: Rc::make_mut(&mut self.inner), - } - } - - pub fn get_mut(&mut self) -> Option<RcVecMut<T>> { - let inner = Rc::get_mut(&mut self.inner)?; - Some(RcVecMut { inner }) - } - - pub fn make_owned(mut self) -> RcVecBuilder<T> - where - T: Clone, - { - let vec = if let Some(owned) = Rc::get_mut(&mut self.inner) { - mem::take(owned) - } else { - Vec::clone(&self.inner) - }; - RcVecBuilder { inner: vec } - } -} - -impl<T> RcVecBuilder<T> { - pub fn new() -> Self { - RcVecBuilder { inner: Vec::new() } - } - - pub fn with_capacity(cap: usize) -> Self { - RcVecBuilder { - inner: Vec::with_capacity(cap), - } - } - - pub fn push(&mut self, element: T) { - self.inner.push(element); - } - - pub fn extend(&mut self, iter: impl IntoIterator<Item = T>) { - self.inner.extend(iter); - } - - pub fn as_mut(&mut self) -> RcVecMut<T> { - RcVecMut { - inner: &mut self.inner, - } - } - - pub fn build(self) -> RcVec<T> { - RcVec { - inner: Rc::new(self.inner), - } - } -} - -impl<'a, T> RcVecMut<'a, T> { - pub fn push(&mut self, element: T) { - self.inner.push(element); - } - - pub fn extend(&mut self, iter: impl IntoIterator<Item = T>) { - self.inner.extend(iter); - } - - pub fn pop(&mut self) -> Option<T> { - self.inner.pop() - } - - pub fn as_mut(&mut self) -> RcVecMut<T> { - RcVecMut { inner: self.inner } - } -} - -impl<T> Clone for RcVec<T> { - fn clone(&self) -> Self { - RcVec { - inner: Rc::clone(&self.inner), - } - } -} - -impl<T> IntoIterator for RcVecBuilder<T> { - type Item = T; - type IntoIter = RcVecIntoIter<T>; - - fn into_iter(self) -> Self::IntoIter { - RcVecIntoIter { - inner: self.inner.into_iter(), - } - } -} - -impl<T> Iterator for RcVecIntoIter<T> { - type Item = T; - - fn next(&mut self) -> Option<Self::Item> { - self.inner.next() - } - - fn size_hint(&self) -> (usize, Option<usize>) { - self.inner.size_hint() - } -} - -impl<T> RefUnwindSafe for RcVec<T> where T: RefUnwindSafe {} |