Skip to main content

Pass

Trait Pass 

Source
pub trait Pass<T>: Sized { }
Expand description

An argument of type T for a function written in Lean: the value itself, which moves into Lean, or a reference to it. A reference to a value that Lean converts, such as a String, is copied. A reference to a value that Lean holds as it is, of an opaque or a foreign type or a collection of import Inlean, is lent for the call: Lean reads the caller’s value, and clones it only where it needs one of its own.

A value may also come in what holds it: a Box, a reference to a Box, an Rc or an Arc, or a Cow. A String also takes a &str, and a Vec<T> a slice or an array of T.

let name = String::from("ada");
shout(&name);  // copied: a `String` is converted
shout("ada");  // copied
shout(name);   // moved: Lean's string is this buffer

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Pass<String> for &str

Source§

impl Pass<String> for Cow<'_, str>

Source§

impl<T, const N: usize> Pass<Vec<T>> for [T; N]

Source§

impl<T: Clone, const N: usize> Pass<Vec<T>> for &[T; N]

Source§

impl<T: Clone> Pass<T> for Cow<'_, T>

Source§

impl<T: Clone> Pass<Vec<T>> for &[T]

Source§

impl<T: Clone> Pass<Vec<T>> for Cow<'_, [T]>

Source§

impl<T> Pass<T> for &Arc<T>

Source§

impl<T> Pass<T> for &Box<T>

Source§

impl<T> Pass<T> for &Rc<T>

Source§

impl<T> Pass<T> for &T

Source§

impl<T> Pass<T> for Box<T>

Implementors§

Source§

impl<T> Pass<T> for T