Skip to main content

Convert

Trait Convert 

Source
pub trait Convert<S: Copy, D> {
    // Required method
    fn one(&self, x: S) -> D;

    // Provided methods
    fn slice(&self, d: &mut Vec<D>, s: &[S]) { ... }
    fn all(&self, s: &[S]) -> Vec<D> { ... }
    fn same<'a>(&self, _d: &'a mut Vec<D>) -> Option<&'a mut Vec<S>> { ... }
    fn borrowed<'a>(&self, _s: &'a [S]) -> Option<&'a [D]> { ... }
}
Expand description

How walk and scatter_walk turn a source item into a result item. Every Fn(S) -> D converts item by item. Same keeps each item of a source and result of one type as it is.

Required Methods§

Source

fn one(&self, x: S) -> D

x, converted.

Provided Methods§

Source

fn slice(&self, d: &mut Vec<D>, s: &[S])

Appends the items of s, converted, in one contiguous pass.

Source

fn all(&self, s: &[S]) -> Vec<D>

The items of s, converted, in one contiguous pass.

Source

fn same<'a>(&self, _d: &'a mut Vec<D>) -> Option<&'a mut Vec<S>>

d as a buffer of source items, where the conversion keeps each item as it is.

Source

fn borrowed<'a>(&self, _s: &'a [S]) -> Option<&'a [D]>

s as result items, where the conversion keeps each item as it is.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: Copy, D, F: Fn(S) -> D> Convert<S, D> for F

Source§

impl<T: Copy> Convert<T, T> for Same