orx_imp_vec

Struct ImpVec

source
pub struct ImpVec<T, P = SplitVec<T>>
where P: PinnedVec<T>,
{ /* private fields */ }
Expand description

ImpVec, stands for immutable push vector ๐Ÿ‘ฟ, is a data structure which allows appending elements with a shared reference.

Specifically, it extends vector capabilities with the following two methods:

  • fn imp_push(&self, value: T)
  • fn imp_extend_from_slice(&self, slice: &[T])

Note that both of these methods can be called with &self rather than &mut self.

ยงMotivation

Appending to a vector with a shared reference sounds unconventional, and it is. However, if we consider our vector as a bag of or a container of things rather than having a collective meaning; then, appending element or elements to the end of the vector:

  • does not mutate any of already added elements, and hence,
  • it is not different than creating a new element in the scope.

ยงSafety

It is natural to expect that appending elements to a vector does not affect already added elements. However, this is usually not the case due to underlying memory management. For instance, std::vec::Vec may move already added elements to different memory locations to maintain the contagious layout of the vector.

PinnedVec prevents such implicit changes in memory locations. It guarantees that push and extend methods keep memory locations of already added elements intact. Therefore, it is perfectly safe to hold on to references of the vector while appending elements.

Consider the classical example that does not compile, which is often presented to highlight the safety guarantees of rust:

let mut vec = vec![0, 1, 2, 3];

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.push(4);

// does not compile due to the following reason:  cannot borrow `vec` as mutable because it is also borrowed as immutable
// assert_eq!(ref_to_first, &0);

This wonderful feature of the borrow checker of rust is not required and used for imp_push and imp_extend_from_slice methods of ImpVec since these methods do not require a &mut self reference. Therefore, the following code compiles and runs perfectly safely.

use orx_imp_vec::*;

let mut vec = ImpVec::new();
vec.extend_from_slice(&[0, 1, 2, 3]);

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.imp_push(4);
assert_eq!(vec.len(), 5);

vec.imp_extend_from_slice(&[6, 7]);
assert_eq!(vec.len(), 7);

assert_eq!(ref_to_first, &0);

Implementationsยง

sourceยง

impl<T, P: PinnedVec<T>> ImpVec<T, P>

source

pub fn into_inner(self) -> P

Consumes the imp-vec into the wrapped inner pinned vector.

ยงExample
use orx_split_vec::SplitVec;
use orx_imp_vec::ImpVec;

let pinned_vec = SplitVec::new();

let imp_vec = ImpVec::from(pinned_vec);
imp_vec.imp_push(42);

let pinned_vec = imp_vec.into_inner();
assert_eq!(&pinned_vec, &[42]);
source

pub fn imp_push(&self, value: T)

Pushes the value to the vector. This method differs from the push method with the required reference. Unlike push, imp_push allows to push the element with a shared reference.

ยงExample
use orx_imp_vec::*;

let mut vec = ImpVec::new();

// regular push with &mut self
vec.push(42);

// hold on to a reference to the first element
let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &42);

// imp_push with &self
vec.imp_push(7);

// due to `PinnedVec` guarantees, this push will never invalidate prior references
assert_eq!(ref_to_first, &42);
ยงSafety

Wrapping a PinnedVec with an ImpVec provides with two additional methods: imp_push and imp_extend_from_slice. Note that these push and extend methods grow the vector by appending elements to the end.

It is natural to expect that these operations do not change the memory locations of already added elements. However, this is usually not the case due to underlying allocations. For instance, std::vec::Vec may move already added elements in memory to maintain the contagious layout of the vector.

PinnedVec prevents such implicit changes in memory locations. It guarantees that push and extend methods keep memory locations of already added elements intact. Therefore, it is perfectly safe to hold on to references of the vector while appending elements.

Consider the classical example that does not compile, which is often presented to highlight the safety guarantees of rust:

let mut vec = vec![0, 1, 2, 3];

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.push(4);

// does not compile due to the following reason:  cannot borrow `vec` as mutable because it is also borrowed as immutable
// assert_eq!(ref_to_first, &0);

This wonderful feature of the borrow checker of rust is not required and used for imp_push and imp_extend_from_slice methods of ImpVec since these methods do not require a &mut self reference. Therefore, the following code compiles and runs perfectly safely.

use orx_imp_vec::*;

let mut vec = ImpVec::new();
vec.extend_from_slice(&[0, 1, 2, 3]);

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.imp_push(4);
assert_eq!(vec.len(), 5);

assert_eq!(ref_to_first, &0);

Although unconventional, this makes sense when we consider the ImpVec as a bag or container of things, rather than having a collective meaning. In other words, when we do not rely on reduction methods, such as count or sum, appending element or elements to the end of the vector:

  • does not mutate any of already added elements, and hence,
  • it is not different than creating a new element in the scope.
Examples found in repository?
examples/system_of_linear_inequalities.rs (lines 138-142)
137
138
139
140
141
142
143
144
    fn mul(self, rhs: Var<'a>) -> Self::Output {
        rhs.scope.terms.imp_push(Term {
            scope: rhs.scope,
            coef: self,
            var: rhs,
        });
        &rhs.scope.terms[rhs.scope.terms.len() - 1]
    }
More examples
Hide additional examples
examples/bag_of_things.rs (lines 10-12)
9
10
11
12
13
14
15
16
17
    fn push_thing(&self, name: &str) -> ThingInBag {
        self.things.imp_push(Thing {
            name: name.to_string(),
        });
        ThingInBag {
            bag: self,
            thing: &self.things[self.things.len() - 1],
        }
    }
examples/expressions.rs (line 17)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    fn symbol(&'a self, name: &'static str) -> ExprInScope<'a> {
        let expr = Expr::Symbol(name);
        self.expressions.imp_push(expr);
        ExprInScope {
            scope: self,
            expr: &self.expressions[self.expressions.len() - 1],
        }
    }
}

/// A recursive expression with three demo variants
enum Expr<'a> {
    Symbol(&'static str),
    Addition(&'a Expr<'a>, &'a Expr<'a>),
    Subtraction(&'a Expr<'a>, &'a Expr<'a>),
}

impl<'a> Display for Expr<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Expr::Symbol(x) => write!(f, "{}", x),
            Expr::Addition(x, y) => write!(f, "{} + {}", x, y),
            Expr::Subtraction(x, y) => write!(f, "{} - {}", x, y),
        }
    }
}

/// Expression in a scope:
/// * it knows what it is
/// * it knows which scope it belongs to
///
/// It can implement Copy which turns out to be extremely important!
#[derive(Clone, Copy)]
struct ExprInScope<'a> {
    scope: &'a Scope<'a>,
    expr: &'a Expr<'a>,
}

impl<'a> ExprInScope<'a> {
    /// Recall, it knows the scope it belongs to,
    /// and can check it in O(1)
    fn belongs_to_same_scope(&self, other: Self) -> bool {
        let self_scope = self.scope as *const Scope;
        let other_scope = other.scope as *const Scope;
        self_scope == other_scope
    }
}
impl<'a> Display for ExprInScope<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.expr)
    }
}

impl<'a> Add for ExprInScope<'a> {
    type Output = ExprInScope<'a>;

    /// We can create an expression by adding two expressions
    ///
    /// Where do we store the new expression?
    ///
    /// Of course, in the scope that both expressions belong to.
    /// And we can do so by `imp_push`.
    ///
    /// # Panics
    ///
    /// Panics if the lhs & rhs do not belong to the same scope.
    fn add(self, rhs: Self) -> Self::Output {
        assert!(self.belongs_to_same_scope(rhs));
        let expressions = &self.scope.expressions;
        let expr = Expr::Addition(self.expr, rhs.expr);
        expressions.imp_push(expr);
        ExprInScope {
            scope: self.scope,
            expr: &expressions[expressions.len() - 1],
        }
    }
}

impl<'a> Sub for ExprInScope<'a> {
    type Output = ExprInScope<'a>;

    /// Similarly, we can create an expression by subtracting two expressions
    ///
    /// Where do we store the new expression?
    ///
    /// Of course, in the scope that both expressions belong to.
    /// And we can do so by `imp_push`.
    ///
    /// # Panics
    ///
    /// Panics if the lhs & rhs do not belong to the same scope.
    fn sub(self, rhs: Self) -> Self::Output {
        assert!(self.belongs_to_same_scope(rhs));
        let expressions = &self.scope.expressions;
        let expr = Expr::Subtraction(self.expr, rhs.expr);
        expressions.imp_push(expr);
        ExprInScope {
            scope: self.scope,
            expr: &expressions[expressions.len() - 1],
        }
    }
source

pub fn imp_push_get_ref(&self, value: T) -> &T

Pushes the value to the vector and returns a reference to it.

It is the composition of vec.imp_push(value) call followed by &vec[vec.len() - 1].

ยงExamples

This method provides a shorthand for the following common use case.

use orx_imp_vec::*;

let vec = ImpVec::new();

vec.imp_push('a');
let a = &vec[vec.len() - 1];
assert_eq!(a, &'a');

// or with imp_push_get_ref

let b = vec.imp_push_get_ref('b');
assert_eq!(b, &'b');
Examples found in repository?
examples/vector_var_imp_vec.rs (line 27)
22
23
24
25
26
27
28
    fn index(&self, index: usize) -> &Self::Output {
        let var = Var {
            index,
            vector: self,
        };
        self.created_vars.imp_push_get_ref(var)
    }
More examples
Hide additional examples
examples/system_of_linear_inequalities.rs (lines 28-31)
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    fn new_var_vec(&'a self, symbol: &str) -> &'a Vector<'a> {
        self.vectors.imp_push_get_ref(Vector {
            scope: self,
            symbol: symbol.to_string(),
        })
    }
}

/// # VarVec
struct Vector<'a> {
    scope: &'a Scope<'a>,
    symbol: String,
}

impl<'a> Display for Vector<'a> {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "{}", self.symbol)
    }
}

impl<'a> Index<usize> for &'a Vector<'a> {
    type Output = Var<'a>;

    fn index(&self, index: usize) -> &Self::Output {
        self.scope.vars.imp_push_get_ref(Var {
            scope: self.scope,
            var_vec: self,
            index,
        })
    }
}

/// # Expr
struct Expr<'a> {
    scope: &'a Scope<'a>,
    terms: Vec<&'a Term<'a>>,
}

impl<'a> Display for Expr<'a> {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        let mut terms = self.terms.iter();
        if let Some(term) = terms.next() {
            write!(f, "{}", term)?;
            for term in terms {
                write!(f, " + {}", term)?;
            }
        }
        Ok(())
    }
}

impl<'a> Add<&'a Term<'a>> for &'a Expr<'a> {
    type Output = &'a Expr<'a>;

    fn add(self, rhs: &'a Term<'a>) -> Self::Output {
        assert!(self.scope.same_scope_as(rhs.scope));

        let mut terms = self.terms.clone();
        terms.push(rhs);
        self.scope.exprs.imp_push_get_ref(Expr {
            scope: self.scope,
            terms,
        })
    }
}

/// # Term
#[derive(Clone, Copy)]
struct Term<'a> {
    scope: &'a Scope<'a>,
    coef: i64,
    var: Var<'a>,
}

impl<'a> Display for Term<'a> {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "{}.{}", self.coef, self.var)
    }
}

impl<'a> Add<&'a Term<'a>> for &'a Term<'a> {
    type Output = &'a Expr<'a>;

    fn add(self, rhs: &'a Term<'a>) -> Self::Output {
        assert!(self.scope.same_scope_as(rhs.scope));

        self.scope.exprs.imp_push_get_ref(Expr {
            scope: self.scope,
            terms: vec![self, rhs],
        })
    }
source

pub fn imp_extend_from_slice(&self, slice: &[T])
where T: Clone,

Extends the vector with the given slice. This method differs from the extend_from_slice method with the required reference. Unlike extend_from_slice, imp_extend_from_slice allows to push the element with a shared reference.

ยงExample
use orx_imp_vec::*;

let mut vec = ImpVec::new();

// regular extend_from_slice with &mut self
vec.extend_from_slice(&[42]);

// hold on to a reference to the first element
let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &42);

// imp_extend_from_slice with &self
vec.imp_extend_from_slice(&[0, 1, 2, 3]);
assert_eq!(vec.len(), 5);

// due to `PinnedVec` guarantees, this extend will never invalidate prior references
assert_eq!(ref_to_first, &42);
ยงSafety

Wrapping a PinnedVec with an ImpVec provides with two additional methods: imp_push and imp_extend_from_slice. Note that these push and extend methods grow the vector by appending elements to the end.

It is natural to expect that these operations do not change the memory locations of already added elements. However, this is usually not the case due to underlying allocations. For instance, std::vec::Vec may move already added elements in memory to maintain the contagious layout of the vector.

PinnedVec prevents such implicit changes in memory locations. It guarantees that push and extend methods keep memory locations of already added elements intact. Therefore, it is perfectly safe to hold on to references of the vector while appending elements.

Consider the classical example that does not compile, which is often presented to highlight the safety guarantees of rust:

let mut vec = vec![0];

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.extend_from_slice(&[1, 2, 3, 4]);

// does not compile due to the following reason:  cannot borrow `vec` as mutable because it is also borrowed as immutable
// assert_eq!(ref_to_first, &0);

This wonderful feature of the borrow checker of rust is not required and used for imp_push and imp_extend_from_slice methods of ImpVec since these methods do not require a &mut self reference. Therefore, the following code compiles and runs perfectly safely.

use orx_imp_vec::*;

let mut vec = ImpVec::new();
vec.push(0);

let ref_to_first = &vec[0];
assert_eq!(ref_to_first, &0);

vec.imp_extend_from_slice(&[1, 2, 3, 4]);

assert_eq!(ref_to_first, &0);

Although unconventional, this makes sense when we consider the ImpVec as a bag or container of things, rather than having a collective meaning. In other words, when we do not rely on reduction methods, such as count or sum, appending element or elements to the end of the vector:

  • does not mutate any of already added elements, and hence,
  • it is not different than creating a new element in the scope.
sourceยง

impl<T> ImpVec<T>

source

pub fn new() -> Self

Creates a new empty imp-vec.

Default underlying pinned vector is a new SplitVec<T, Doubling>.

ยงExample
use orx_imp_vec::*;

let imp_vec: ImpVec<char> = ImpVec::new();
assert!(imp_vec.is_empty());
sourceยง

impl<T> ImpVec<T, SplitVec<T, Doubling>>

source

pub fn with_doubling_growth() -> Self

Creates a new ImpVec by creating and wrapping up a new SplitVec<T, Doubling> as the underlying storage.

sourceยง

impl<T> ImpVec<T, SplitVec<T, Recursive>>

source

pub fn with_recursive_growth() -> Self

Creates a new ImpVec by creating and wrapping up a new SplitVec<T, Recursive> as the underlying storage.

sourceยง

impl<T> ImpVec<T, SplitVec<T, Linear>>

source

pub fn with_linear_growth(constant_fragment_capacity_exponent: usize) -> Self

Creates a new ImpVec by creating and wrapping up a new SplitVec<T, Linear> as the underlying storage.

  • Each fragment of the underlying split vector will have a capacity of 2 ^ constant_fragment_capacity_exponent.
sourceยง

impl<T> ImpVec<T, FixedVec<T>>

source

pub fn with_fixed_capacity(fixed_capacity: usize) -> Self

Creates a new ImpVec by creating and wrapping up a new FixedVec<T> as the underlying storage.

ยงSafety

Note that a FixedVec cannot grow beyond the given fixed_capacity. In other words, has a hard upper bound on the number of elements it can hold, which is the fixed_capacity.

Pushing to the vector beyond this capacity leads to โ€œout-of-capacityโ€ error.

This maximum capacity can be accessed by the capacitymethod.

Trait Implementationsยง

sourceยง

impl<T, P> Clone for ImpVec<T, P>
where P: PinnedVec<T> + Clone,

sourceยง

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 ยท sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
sourceยง

impl<T: Debug, P: PinnedVec<T> + Debug> Debug for ImpVec<T, P>

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
sourceยง

impl<T> Default for ImpVec<T>

sourceยง

fn default() -> Self

Creates a new empty imp-vec.

ยงExample
use orx_imp_vec::*;

let imp_vec: ImpVec<usize> = ImpVec::default();
assert!(imp_vec.is_empty());
sourceยง

impl<T, P: PinnedVec<T>> Deref for ImpVec<T, P>

sourceยง

type Target = P

The resulting type after dereferencing.
sourceยง

fn deref(&self) -> &Self::Target

Dereferences the value.
sourceยง

impl<T, P: PinnedVec<T>> DerefMut for ImpVec<T, P>

sourceยง

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
sourceยง

impl<T, P: PinnedVec<T>> From<P> for ImpVec<T, P>

sourceยง

fn from(pinned_vec: P) -> Self

Converts to this type from the input type.
sourceยง

impl<T, P> FromIterator<T> for ImpVec<T, P>
where P: FromIterator<T> + PinnedVec<T>,

sourceยง

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
sourceยง

impl<T, P: PinnedVec<T>> Index<usize> for ImpVec<T, P>

sourceยง

type Output = T

The returned type after indexing.
sourceยง

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
sourceยง

impl<T, P: PinnedVec<T>> IndexMut<usize> for ImpVec<T, P>

sourceยง

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
sourceยง

impl<T, P: PinnedVec<T>> IntoIterator for ImpVec<T, P>

sourceยง

type Item = T

The type of the elements being iterated over.
sourceยง

type IntoIter = <P as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
sourceยง

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<[T]> for ImpVec<T, P>

sourceยง

fn eq(&self, other: &[T]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<FixedVec<T>> for ImpVec<T, P>

sourceยง

fn eq(&self, other: &FixedVec<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<ImpVec<T, P>> for [T]

sourceยง

fn eq(&self, other: &ImpVec<T, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<ImpVec<T, P>> for FixedVec<T>

sourceยง

fn eq(&self, other: &ImpVec<T, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>, G: Growth> PartialEq<ImpVec<T, P>> for SplitVec<T, G>

sourceยง

fn eq(&self, other: &ImpVec<T, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<ImpVec<T, P>> for Vec<T>

sourceยง

fn eq(&self, other: &ImpVec<T, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P1: PinnedVec<T>, P2: PinnedVec<T>> PartialEq<ImpVec<T, P2>> for ImpVec<T, P1>

sourceยง

fn eq(&self, other: &ImpVec<T, P2>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>, G: Growth> PartialEq<SplitVec<T, G>> for ImpVec<T, P>

sourceยง

fn eq(&self, other: &SplitVec<T, G>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl<T: PartialEq, P: PinnedVec<T>> PartialEq<Vec<T>> for ImpVec<T, P>

sourceยง

fn eq(&self, other: &Vec<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementationsยง

ยง

impl<T, P = SplitVec<T>> !Freeze for ImpVec<T, P>

ยง

impl<T, P = SplitVec<T>> !RefUnwindSafe for ImpVec<T, P>

ยง

impl<T, P> Send for ImpVec<T, P>
where P: Send, T: Send,

ยง

impl<T, P = SplitVec<T>> !Sync for ImpVec<T, P>

ยง

impl<T, P> Unpin for ImpVec<T, P>
where P: Unpin, T: Unpin,

ยง

impl<T, P> UnwindSafe for ImpVec<T, P>
where P: UnwindSafe, T: UnwindSafe,

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
sourceยง

impl<T> CloneToUninit for T
where T: Clone,

sourceยง

unsafe fn clone_to_uninit(&self, dst: *mut T)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

sourceยง

impl<T> ToOwned for T
where T: Clone,

sourceยง

type Owned = T

The resulting type after obtaining ownership.
sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.