typst_utils

Trait Get

source
pub trait Get<Index> {
    type Component;

    // Required methods
    fn get_ref(&self, index: Index) -> &Self::Component;
    fn get_mut(&mut self, index: Index) -> &mut Self::Component;

    // Provided methods
    fn get(self, index: Index) -> Self::Component
       where Self: Sized,
             Self::Component: Copy { ... }
    fn set(&mut self, index: Index, component: Self::Component) { ... }
}
Expand description

Generic access to a structure’s components.

Required Associated Types§

source

type Component

The structure’s component type.

Required Methods§

source

fn get_ref(&self, index: Index) -> &Self::Component

Borrow the component for the specified index.

source

fn get_mut(&mut self, index: Index) -> &mut Self::Component

Borrow the component for the specified index mutably.

Provided Methods§

source

fn get(self, index: Index) -> Self::Component
where Self: Sized, Self::Component: Copy,

Convenience method for getting a copy of a component.

source

fn set(&mut self, index: Index, component: Self::Component)

Convenience method for setting a component.

Implementors§