Skip to main content

HistoryTree

Struct HistoryTree 

Source
pub struct HistoryTree<E, Cmd = ()> { /* private fields */ }
Expand description

A history tree for non-linear undo-redo action.

Implementations§

Source§

impl<Cmd: Default, E: Default> HistoryTree<E, Cmd>

Source

pub fn new() -> Self

Create a new history tree.

Examples found in repository?
examples/history_tree.rs (line 9)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}
Source§

impl<Cmd, E> HistoryTree<E, Cmd>

Source

pub fn curr_node(&self) -> HistoryTreeNodeId

Returns the id of the current node.

Examples found in repository?
examples/history_tree.rs (line 17)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}
Source

pub fn node(&self, id: HistoryTreeNodeId) -> &HistoryTreeNode<E, Cmd>

Returns an immutable reference to the node with the given id.

Examples found in repository?
examples/history_tree.rs (line 65)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}
Source

pub fn parent(&self, id: HistoryTreeNodeId) -> Option<HistoryTreeNodeId>

Returns parent node id of the node with the given id. None for the root.

Source

pub fn cmd(&self, id: HistoryTreeNodeId) -> &Cmd

Returns an immutable reference to the command metadata at the given node.

Source

pub fn cmd_mut(&mut self, id: HistoryTreeNodeId) -> &mut Cmd

Returns a mutable reference to the command metadata at the given node.

Source§

impl<Cmd: Default, E> HistoryTree<E, Cmd>

Source

pub fn commit<T>(&mut self, target: &mut T)
where E: ExtractEdit<T>,

Flush the target container and insert its changes as an edit into a new tree leaf under the current node.

Examples found in repository?
examples/history_tree.rs (line 15)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}
Source§

impl<Cmd, E> HistoryTree<E, Cmd>

Source

pub fn cmd_commit<T>(&mut self, cmd: Cmd, target: &mut T)
where E: ExtractEdit<T>,

Flush the target container and insert its changes into a new tree leaf under the current node as an edit along with additional metadata (“cmd”).

Source§

impl<Cmd: Clone, E: Clone> HistoryTree<E, Cmd>

Source

pub fn undo<T>(&mut self, target: &mut T) -> Option<Cmd>
where E: RevertEdit<T>,

Undo the edit at the current tree node, moving one step upwards to the node’s parent.

This does not cause any changes to the tree topology, only the target container and current node are modified.

Examples found in repository?
examples/history_tree.rs (line 40)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}
Source

pub fn redo<T>(&mut self, target: &mut T, node: HistoryTreeNodeId) -> Cmd
where E: ApplyEdit<T> + RevertEdit<T>,

Redo the edit at the specified node, moving one step downwards.

This does not cause any changes to the tree topology, only the target container and current node are modified.

Source

pub fn checkout<T>( &mut self, target: &mut T, target_node: HistoryTreeNodeId, ) -> Vec<Cmd>
where E: ApplyEdit<T> + RevertEdit<T>,

Move from the current node to the target node.

First, a sequence of calls to Self::undo is made to climb to the lowest common ancestor, and then a sequence of calls to Self::redo is performed to descend to the target node.

Returns the list of command metadata produced by the redo phase in the order they were applied. If already at target_node, an empty vector is returned.

Examples found in repository?
examples/history_tree.rs (line 83)
8fn main() {
9    let mut history_tree: HistoryTree<VecDelta<&str>> = HistoryTree::new();
10    let mut state = Recorder::new(vec!["root"]);
11
12    // Right below the root we push a "fork" node, from which we will fork two
13    // branches.
14    state.push("fork");
15    history_tree.commit(&mut state);
16
17    let fork = history_tree.curr_node();
18
19    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
20
21    // Add first node of left branch.
22    state.push("left_branch_1");
23    history_tree.commit(&mut state);
24
25    let left_branch_1 = history_tree.curr_node();
26
27    // Add second node of left branch.
28    state.push("left_branch_2");
29    history_tree.commit(&mut state);
30
31    let left_branch_2 = history_tree.curr_node();
32
33    // Now we have assembled the whole of the left branch.
34    assert_eq!(
35        *state.as_ref(),
36        vec!["root", "fork", "left_branch_1", "left_branch_2"]
37    );
38
39    // Let's now undo the whole left branch up to the fork node.
40    history_tree.undo(&mut state);
41    history_tree.undo(&mut state);
42
43    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
44    assert_eq!(history_tree.curr_node(), fork);
45
46    // Add first node of right branch.
47    state.push("right_branch_1");
48    history_tree.commit(&mut state);
49
50    let right_branch_1 = history_tree.curr_node();
51
52    // Add second node of right branch.
53    state.push("right_branch_2");
54    history_tree.commit(&mut state);
55
56    let right_branch_2 = history_tree.curr_node();
57
58    // Now we have assembled the whole of the right branch.
59    assert_eq!(
60        *state.as_ref(),
61        vec!["root", "fork", "right_branch_1", "right_branch_2"]
62    );
63
64    let root_children = history_tree
65        .node(history_tree.node(fork).parent().unwrap())
66        .children();
67    assert_eq!(root_children, &[fork]);
68
69    assert_eq!(
70        history_tree.node(fork).children(),
71        &[left_branch_1, right_branch_1]
72    );
73    assert_eq!(
74        history_tree.node(left_branch_1).children(),
75        &[left_branch_2]
76    );
77    assert_eq!(
78        history_tree.node(right_branch_1).children(),
79        &[right_branch_2]
80    );
81
82    // Check out left branch from the apex of the right branch.
83    history_tree.checkout(&mut state, left_branch_2);
84
85    assert_eq!(history_tree.curr_node(), left_branch_2);
86    assert_eq!(
87        *state.as_ref(),
88        vec!["root", "fork", "left_branch_1", "left_branch_2"]
89    );
90
91    // Check out the right branch from the apex of the left branch.
92    history_tree.checkout(&mut state, right_branch_2);
93
94    assert_eq!(history_tree.curr_node(), right_branch_2);
95    assert_eq!(
96        *state.as_ref(),
97        vec!["root", "fork", "right_branch_1", "right_branch_2"]
98    );
99
100    // Let's now undo the whole right branch up to the fork node.
101    history_tree.undo(&mut state);
102    history_tree.undo(&mut state);
103
104    assert_eq!(*state.as_ref(), vec!["root", "fork"]);
105    assert_eq!(history_tree.curr_node(), fork);
106}

Trait Implementations§

Source§

impl<E: Clone, Cmd: Clone> Clone for HistoryTree<E, Cmd>

Source§

fn clone(&self) -> HistoryTree<E, Cmd>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<E: Debug, Cmd: Debug> Debug for HistoryTree<E, Cmd>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<E: Eq, Cmd: Eq> Eq for HistoryTree<E, Cmd>

Source§

impl<E: Hash, Cmd: Hash> Hash for HistoryTree<E, Cmd>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E: PartialEq, Cmd: PartialEq> PartialEq for HistoryTree<E, Cmd>

Source§

fn eq(&self, other: &HistoryTree<E, Cmd>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<E: PartialEq, Cmd: PartialEq> StructuralPartialEq for HistoryTree<E, Cmd>

Auto Trait Implementations§

§

impl<E, Cmd> Freeze for HistoryTree<E, Cmd>
where Vec<HistoryTreeNode<E, Cmd>>: Freeze,

§

impl<E, Cmd> RefUnwindSafe for HistoryTree<E, Cmd>

§

impl<E, Cmd> Send for HistoryTree<E, Cmd>
where Vec<HistoryTreeNode<E, Cmd>>: Send,

§

impl<E, Cmd> Sync for HistoryTree<E, Cmd>
where Vec<HistoryTreeNode<E, Cmd>>: Sync,

§

impl<E, Cmd> Unpin for HistoryTree<E, Cmd>
where Vec<HistoryTreeNode<E, Cmd>>: Unpin,

§

impl<E, Cmd> UnsafeUnpin for HistoryTree<E, Cmd>

§

impl<E, Cmd> UnwindSafe for HistoryTree<E, Cmd>
where Vec<HistoryTreeNode<E, Cmd>>: 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.