Struct std::path::Components
[−]
[src]
pub struct Components<'a> { // some fields omitted }
The core iterator giving the components of a path.
See the module documentation for an in-depth explanation of components and their role in the API.
Examples
fn main() { use std::path::Path; let path = Path::new("/tmp/foo/bar.txt"); for component in path.components() { println!("{:?}", component); } }use std::path::Path; let path = Path::new("/tmp/foo/bar.txt"); for component in path.components() { println!("{:?}", component); }
Methods
impl<'a> Components<'a>
fn as_path(&self) -> &'a Path
Extracts a slice corresponding to the portion of the path remaining for iteration.
Examples
fn main() { use std::path::Path; let path = Path::new("/tmp/foo/bar.txt"); println!("{:?}", path.components().as_path()); }use std::path::Path; let path = Path::new("/tmp/foo/bar.txt"); println!("{:?}", path.components().as_path());
fn peek(&self) -> Option<Component<'a>>
Unstable (
path_components_peek
#27727)Examine the next component without consuming it.