PathExtGuaranteed

Trait PathExtGuaranteed 

Source
pub trait PathExtGuaranteed: PathExt {
    // Provided methods
    fn borrow(&self) -> Ref<'_, <Self as Path>::Out> { ... }
    fn borrow_mut(&self) -> BorrowMutGuard<'_, Self> { ... }
    fn borrow_mut_without_notifying(&self) -> RefMut<'_, <Self as Path>::Out> { ... }
    fn get(&self) -> Self::Out
       where Self::Out: Clone { ... }
    fn set(&self, data: Self::Out)
       where Self::Out: Sized { ... }
}
Expand description

Implemented for Path objects that will always be able to obtain their data piece.

Such paths are those that

  • don’t go through any enum (if the enum is in a different variant, then the data cannot be obtained)
  • don’t go through Vec or HashMap (the requested item might not be in the collection)

The methods in this trait are similar to the borrow methods in PathExt, but they don’t return Option because we know the data is always there.

Provided Methods§

Source

fn borrow(&self) -> Ref<'_, <Self as Path>::Out>

Borrow the data at this path immutably.

See borrow_opt for more details.

Source

fn borrow_mut(&self) -> BorrowMutGuard<'_, Self>

Borrow the data at this path mutably, notifying all the relevant change listeners when the returned borrow guard is dropped.

See borrow_opt_mut for more details.

Source

fn borrow_mut_without_notifying(&self) -> RefMut<'_, <Self as Path>::Out>

Borrow the data at this path mutably without notifying any listener.

See borrow_opt_mut_without_notifying for more details.

Source

fn get(&self) -> Self::Out
where Self::Out: Clone,

Clone the data identified by this path.

Equivalent to path.borrow().clone().

Source

fn set(&self, data: Self::Out)
where Self::Out: Sized,

Set the data identified by this path, notifying listeners.

Equivalent to *path.borrow_mut() = data;

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§