pub struct TreePrinter { /* private fields */ }
Implementations§
Source§impl TreePrinter
impl TreePrinter
Sourcepub fn new() -> TreePrinter
pub fn new() -> TreePrinter
Examples found in repository?
examples/atree.rs (line 25)
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);
}
Sourcepub fn print<T>(&self, tree: &Tree<T>)
pub fn print<T>(&self, tree: &Tree<T>)
Examples found in repository?
examples/atree.rs (line 26)
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§
Source§impl Debug for TreePrinter
impl Debug for TreePrinter
Auto Trait Implementations§
impl !Freeze for TreePrinter
impl !RefUnwindSafe for TreePrinter
impl Send for TreePrinter
impl !Sync for TreePrinter
impl Unpin for TreePrinter
impl UnwindSafe for TreePrinter
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.