pub struct Path<T>{ /* private fields */ }
Expand description
Represents a path to a specific element in the tree structure. Not that
parameter T
shall be of the same type as for the corresponding Tree<T>
.
Implementations§
Source§impl<'a, T> Path<T>
impl<'a, T> Path<T>
Sourcepub fn from(elements: Vec<T>) -> Path<T>
pub fn from(elements: Vec<T>) -> Path<T>
Creates a new Path<T>
based on the given elements. Note that the takes
ownership of the provided elements
.
Examples found in repository?
examples/atree.rs (line 34)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
fn main() {
let mut root = MyTree::new("root".to_string());
let mut s1 = MyTree::new("s1".to_string());
let mut s1_s1 = MyTree::new("s1_s1".to_string());
let s1_s1_s1 = MyTree::new("s1_s1_s1".to_string());
let s1_s1_s2 = MyTree::new("s1_s1_s2".to_string());
let s1_s2 = MyTree::new("s1_s2".to_string());
let s1_s3 = MyTree::new("s1_s3".to_string());
s1_s1.add(s1_s1_s1);
s1_s1.add(s1_s1_s2);
s1.add(s1_s1);
s1.add(s1_s2);
s1.add(s1_s3);
let s2 = MyTree::new("s2".to_string());
root.add(s1);
root.add(s2);
let printer = tree::TreePrinter::new();
printer.print(&root);
for e in &root {
println!("{}", e);
}
let e = ["root", "s1", "s1_s1"].iter().map(|x| x.to_string()).collect();
let p = tree::Path::from(e);
let r = root.remove(&p);
if r {
println!("It has been removed!");
} else {
println!("Nothing has been removed!");
}
printer.print(&root);
}
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Path<T>
impl<T> RefUnwindSafe for Path<T>where
T: RefUnwindSafe,
impl<T> Send for Path<T>where
T: Send,
impl<T> Sync for Path<T>where
T: Sync,
impl<T> Unpin for Path<T>where
T: Unpin,
impl<T> UnwindSafe for Path<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.