pub struct Fral<T> { /* private fields */ }Expand description
An Arc-based functional random access list.
Implementations§
Source§impl<T> Fral<T>
impl<T> Fral<T>
Sourcepub fn get(&self, index: usize) -> Option<Arc<T>>
pub fn get(&self, index: usize) -> Option<Arc<T>>
Returns a reference to an element, or None if it is out of bounds.
Time: O(log n)
§Examples
let f: Fral<_> = vec![7, 0, 17].into_iter().rev().collect();
assert_eq!(f.get(2), Some(Arc::new(17)));Sourcepub fn cons<R>(&self, x: R) -> Fral<T>where
R: AsArc<T>,
pub fn cons<R>(&self, x: R) -> Fral<T>where
R: AsArc<T>,
Insert an element at the front of the list.
Time: O(1)
Sourcepub fn uncons(&self) -> Option<(Arc<T>, Fral<T>)>
pub fn uncons(&self) -> Option<(Arc<T>, Fral<T>)>
Get the head and tail of the list.
Time: O(1)
pub fn iter(&self) -> Iter<T> ⓘ
Trait Implementations§
Source§impl<T, R: AsArc<T>> FromIterator<R> for Fral<T>
This is done with repeated cons, so you may intend to reverse your iterator first.
impl<T, R: AsArc<T>> FromIterator<R> for Fral<T>
This is done with repeated cons, so you may intend to reverse your iterator first.
§Examples
let items = vec![1, 2, 3];
let f: Fral<_> = items.into_iter().collect();
// the first item in f is the last item of the iterator
assert_eq!(f.get(0), Some(Arc::new(3)));Source§impl<T> IntoIterator for Fral<T>
impl<T> IntoIterator for Fral<T>
impl<T: Eq> Eq for Fral<T>
impl<T> StructuralPartialEq for Fral<T>
Auto Trait Implementations§
impl<T> Freeze for Fral<T>
impl<T> RefUnwindSafe for Fral<T>where
T: RefUnwindSafe,
impl<T> Send for Fral<T>
impl<T> Sync for Fral<T>
impl<T> Unpin for Fral<T>
impl<T> UnwindSafe for Fral<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more