pub struct Nodes<'a> { /* private fields */ }Implementations§
Source§impl<'a> Nodes<'a>
impl<'a> Nodes<'a>
Sourcepub fn iter(&self) -> impl Iterator<Item = &'a str> + '_
pub fn iter(&self) -> impl Iterator<Item = &'a str> + '_
Get an iterator over the nodes
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM TCM BCM")?;
for node in dbc.nodes().iter() {
println!("Node: {}", node);
}Sourcepub fn contains(&self, node: &str) -> bool
pub fn contains(&self, node: &str) -> bool
Check if a node is in the list
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM TCM")?;
assert!(dbc.nodes().contains("ECM"));
assert!(!dbc.nodes().contains("BCM"));Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of nodes
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM TCM BCM")?;
assert_eq!(dbc.nodes().len(), 3);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no nodes
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"")?;
assert!(dbc.nodes().is_empty());Sourcepub fn at(&self, index: usize) -> Option<&'a str>
pub fn at(&self, index: usize) -> Option<&'a str>
Get a node by index, or None if index is out of bounds
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM TCM")?;
if let Some(node) = dbc.nodes().at(0) {
assert_eq!(node, "ECM");
}pub fn to_dbc_string(&self) -> String
Trait Implementations§
impl<'a> Eq for Nodes<'a>
impl<'a> StructuralPartialEq for Nodes<'a>
Auto Trait Implementations§
impl<'a> Freeze for Nodes<'a>
impl<'a> RefUnwindSafe for Nodes<'a>
impl<'a> Send for Nodes<'a>
impl<'a> Sync for Nodes<'a>
impl<'a> Unpin for Nodes<'a>
impl<'a> UnwindSafe for Nodes<'a>
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