vexide_core::path

Struct Path

Source
pub struct Path { /* private fields */ }
Expand description

A slice of a path (akin to str).

More details about the overall approach can be found in the module documentation.

Implementations§

Source§

impl Path

Source

pub fn new<'a, P: AsRef<FsStr> + 'a>(path: P) -> &'a Self

Directly wraps a string slice as a Path slice.

This is a cost-free conversion.

§Examples
use vexide::core::path::Path;

Path::new("foo.txt");

You can create Paths from Strings, or even other Paths:

use alloc::string::String;
use vexide::core::path::Path;

let string = String::from("foo.txt");
let from_string = Path::new(&string);
let from_path = Path::new(&from_string);
assert_eq!(from_string, from_path);
Source

pub const fn as_fs_str(&self) -> &FsStr

Yields the underlying FsStr slice.

§Examples
use vexide::core::{path::Path, fs::FsStr};

let fs_str = Path::new("foo.txt").as_os_str();
assert_eq!(os_str, FsStr::new("foo.txt"));

Trait Implementations§

Source§

impl AsRef<Path> for &str

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Path> for Path

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl !Sized for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnwindSafe for Path

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more