Struct NodeId

pub struct NodeId { /* private fields */ }
Expand description

A node identifier within a particular Arena.

This ID is used to get Node references from an Arena.

Implementations§

§

impl NodeId

pub fn is_removed<T>(self, arena: &Arena<T>) -> bool

Return if the Node of NodeId point to is removed.

pub fn ancestors<T>(self, arena: &Arena<T>) -> Ancestors<'_, T>

Returns an iterator of IDs of this node and its ancestors.

Use .skip(1) or call .next() once on the iterator to skip the node itself.

§Examples
// arena
// `-- 1                                                // #3
//     |-- 1_1                                          // #2
//     |   `-- 1_1_1 *                                  // #1
//     |       `-- 1_1_1_1
//     _-- 1_2
//     `-- 1_3

let mut iter = n1_1_1.ancestors(&arena);
assert_eq!(iter.next(), Some(n1_1_1));                  // #1
assert_eq!(iter.next(), Some(n1_1));                    // #2
assert_eq!(iter.next(), Some(n1));                      // #3
assert_eq!(iter.next(), None);

pub fn predecessors<T>(self, arena: &Arena<T>) -> Predecessors<'_, T>

Returns an iterator of IDs of this node and its predecessors.

Use .skip(1) or call .next() once on the iterator to skip the node itself.

§Examples
// arena
// `-- 1                                                // #3
//     |-- 1_1                                          // #2
//     |   `-- 1_1_1 *                                  // #1
//     |       `-- 1_1_1_1
//     _-- 1_2
//     `-- 1_3

let mut iter = n1_1_1.predecessors(&arena);
assert_eq!(iter.next(), Some(n1_1_1));                  // #1
assert_eq!(iter.next(), Some(n1_1));                    // #2
assert_eq!(iter.next(), Some(n1));                      // #3
assert_eq!(iter.next(), None);
// arena
// `-- 1                                                // #4
//     |-- 1_1                                          // #3
//     |-- 1_2                                          // #2
//     |   `-- 1_2_1 *                                  // #1
//     |       `-- 1_2_1_1
//     _-- 1_3
//     `-- 1_4

let mut iter = n1_2_1.predecessors(&arena);
assert_eq!(iter.next(), Some(n1_2_1));                  // #1
assert_eq!(iter.next(), Some(n1_2));                    // #2
assert_eq!(iter.next(), Some(n1_1));                    // #3
assert_eq!(iter.next(), Some(n1));                      // #4
assert_eq!(iter.next(), None);

pub fn preceding_siblings<T>(self, arena: &Arena<T>) -> PrecedingSiblings<'_, T>

Returns an iterator of IDs of this node and the siblings before it.

Use .skip(1) or call .next() once on the iterator to skip the node itself.

§Examples
// arena
// `-- 1
//     |-- 1_1                                          // #2
//     |   `-- 1_1_1
//     |-- 1_2                                          // #1
//     `-- 1_3

let mut iter = n1_2.preceding_siblings(&arena);
assert_eq!(iter.next(), Some(n1_2));                    // #1
assert_eq!(iter.next(), Some(n1_1));                    // #2
assert_eq!(iter.next(), None);

pub fn following_siblings<T>(self, arena: &Arena<T>) -> FollowingSiblings<'_, T>

Returns an iterator of IDs of this node and the siblings after it.

Use .skip(1) or call .next() once on the iterator to skip the node itself.

§Examples
// arena
// `-- 1
//     |-- 1_1
//     |   `-- 1_1_1
//     |-- 1_2                                          // #1
//     `-- 1_3                                          // #2

let mut iter = n1_2.following_siblings(&arena);
assert_eq!(iter.next(), Some(n1_2));                    // #1
assert_eq!(iter.next(), Some(n1_3));                    // #2
assert_eq!(iter.next(), None);

pub fn children<T>(self, arena: &Arena<T>) -> Children<'_, T>

Returns an iterator of IDs of this node’s children.

§Examples
// arena
// `-- 1
//     |-- 1_1                                          // #1
//     |   `-- 1_1_1
//     |-- 1_2                                          // #2
//     `-- 1_3                                          // #3

let mut iter = n1.children(&arena);
assert_eq!(iter.next(), Some(n1_1));                    // #1
assert_eq!(iter.next(), Some(n1_2));                    // #2
assert_eq!(iter.next(), Some(n1_3));                    // #3
assert_eq!(iter.next(), None);

pub fn reverse_children<T>(self, arena: &Arena<T>) -> ReverseChildren<'_, T>

👎Deprecated since 4.7.0: please, use NodeId::children().rev() instead if you want to iterate in reverse

Returns an iterator of IDs of this node’s children, in reverse order.

§Examples
// arena
// `-- 1
//     |-- 1_1                                          // #3
//     |   `-- 1_1_1
//     |-- 1_2                                          // #2
//     `-- 1_3                                          // #1

let mut iter = n1.reverse_children(&arena);
assert_eq!(iter.next(), Some(n1_3));                    // #1
assert_eq!(iter.next(), Some(n1_2));                    // #2
assert_eq!(iter.next(), Some(n1_1));                    // #3
assert_eq!(iter.next(), None);

pub fn descendants<T>(self, arena: &Arena<T>) -> Descendants<'_, T>

An iterator of the IDs of a given node and its descendants, as a pre-order depth-first search where children are visited in insertion order.

i.e. node -> first child -> second child

Parent nodes appear before the descendants. Use .skip(1) or call .next() once on the iterator to skip the node itself.

§Examples
// arena
// `-- 1                                                // #1
//     |-- 1_1                                          // #2
//     |   `-- 1_1_1                                    // #3
//     |       `-- 1_1_1_1                              // #4
//     |-- 1_2                                          // #5
//     `-- 1_3                                          // #6

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));                      // #1
assert_eq!(iter.next(), Some(n1_1));                    // #2
assert_eq!(iter.next(), Some(n1_1_1));                  // #3
assert_eq!(iter.next(), Some(n1_1_1_1));                // #4
assert_eq!(iter.next(), Some(n1_2));                    // #5
assert_eq!(iter.next(), Some(n1_3));                    // #6
assert_eq!(iter.next(), None);

pub fn traverse<T>(self, arena: &Arena<T>) -> Traverse<'_, T>

An iterator of the “sides” of a node visited during a depth-first pre-order traversal, where node sides are visited start to end and children are visited in insertion order.

i.e. node.start -> first child -> second child -> node.end

§Examples
// arena
// `-- 1                                                // #1, #10
//     |-- 1_1                                          // #2, #5
//     |   `-- 1_1_1                                    // #3, #4
//     |-- 1_2                                          // #6, #7
//     `-- 1_3                                          // #8, #9

let mut iter = n1.traverse(&arena);
assert_eq!(iter.next(), Some(NodeEdge::Start(n1)));     // #1
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_1)));   // #2
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_1_1))); // #3
assert_eq!(iter.next(), Some(NodeEdge::End(n1_1_1)));   // #4
assert_eq!(iter.next(), Some(NodeEdge::End(n1_1)));     // #5
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_2)));   // #6
assert_eq!(iter.next(), Some(NodeEdge::End(n1_2)));     // #7
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_3)));   // #8
assert_eq!(iter.next(), Some(NodeEdge::End(n1_3)));     // #9
assert_eq!(iter.next(), Some(NodeEdge::End(n1)));       // #10
assert_eq!(iter.next(), None);

pub fn reverse_traverse<T>(self, arena: &Arena<T>) -> ReverseTraverse<'_, T>

An iterator of the “sides” of a node visited during a depth-first pre-order traversal, where nodes are visited end to start and children are visited in reverse insertion order.

i.e. node.end -> second child -> first child -> node.start

§Examples
// arena
// `-- 1                                                // #1, #10
//     |-- 1_1                                          // #6, #9
//     |   `-- 1_1_1                                    // #7, #8
//     |-- 1_2                                          // #4, #5
//     `-- 1_3                                          // #2, #3

let mut iter = n1.reverse_traverse(&arena);
assert_eq!(iter.next(), Some(NodeEdge::End(n1)));       // #1
assert_eq!(iter.next(), Some(NodeEdge::End(n1_3)));     // #2
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_3)));   // #3
assert_eq!(iter.next(), Some(NodeEdge::End(n1_2)));     // #4
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_2)));   // #5
assert_eq!(iter.next(), Some(NodeEdge::End(n1_1)));     // #6
assert_eq!(iter.next(), Some(NodeEdge::End(n1_1_1)));   // #7
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_1_1))); // #8
assert_eq!(iter.next(), Some(NodeEdge::Start(n1_1)));   // #9
assert_eq!(iter.next(), Some(NodeEdge::Start(n1)));     // #10
assert_eq!(iter.next(), None);
// arena
// `-- 1                                                // #1, #10
//     |-- 1_1                                          // #6, #9
//     |   `-- 1_1_1                                    // #7, #8
//     |-- 1_2                                          // #4, #5
//     `-- 1_3                                          // #2, #3
let traverse = n1.traverse(&arena).collect::<Vec<_>>();
let mut reverse = n1.reverse_traverse(&arena).collect::<Vec<_>>();
reverse.reverse();
assert_eq!(traverse, reverse);

pub fn detach<T>(self, arena: &mut Arena<T>)

Detaches a node from its parent and siblings. Children are not affected.

§Examples
// arena
// `-- (implicit)
//     `-- 1
//         |-- 1_1
//         |   `-- 1_1_1
//         |-- 1_2 *
//         `-- 1_3

n1_2.detach(&mut arena);
// arena
// |-- (implicit)
// |   `-- 1
// |       |-- 1_1
// |       |   `-- 1_1_1
// |       `-- 1_3
// `-- (implicit)
//     `-- 1_2 *

assert!(arena[n1_2].parent().is_none());
assert!(arena[n1_2].previous_sibling().is_none());
assert!(arena[n1_2].next_sibling().is_none());

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_1_1));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), None);

pub fn append<T>(self, new_child: NodeId, arena: &mut Arena<T>)

Appends a new child to this node, after existing children.

§Panics

Panics if:

  • the given new child is self, or
  • the given new child is an ancestor of self, or
  • the current node or the given new child was already removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
let n1_1 = arena.new_node("1_1");
n1.append(n1_1, &mut arena);
let n1_2 = arena.new_node("1_2");
n1.append(n1_2, &mut arena);
let n1_3 = arena.new_node("1_3");
n1.append(n1_3, &mut arena);

// arena
// `-- 1
//     |-- 1_1
//     |-- 1_2
//     `-- 1_3

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_2));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), None);

pub fn checked_append<T>( self, new_child: NodeId, arena: &mut Arena<T>, ) -> Result<(), NodeError>

Appends a new child to this node, after existing children.

§Failures
  • Returns NodeError::AppendSelf error if the given new child is self.
  • Returns [NodeError::AppendAncestor] error if the given new child is an ancestor of self.
  • Returns NodeError::Removed error if the given new child or self is removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
assert!(n1.checked_append(n1, &mut arena).is_err());

let n1_1 = arena.new_node("1_1");
assert!(n1.checked_append(n1_1, &mut arena).is_ok());

pub fn append_value<T>(self, value: T, arena: &mut Arena<T>) -> NodeId

Creates and appends a new node (from its associated data) as the last child. This method is a fast path for the common case of appending a new node. It is quicker than append.

§Panics

Panics if the arena already has usize::max_value() nodes.

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
let n1_1 = n1.append_value("1_1", &mut arena);
let n1_1_1 = n1_1.append_value("1_1_1", &mut arena);
let n1_1_2 = n1_1.append_value("1_1_2", &mut arena);

// arena
// `-- 1
//     |-- 1_1
//  1_1_1 --|-- 1_1_2

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_1_1));
assert_eq!(iter.next(), Some(n1_1_2));
assert_eq!(iter.next(), None);

pub fn prepend<T>(self, new_child: NodeId, arena: &mut Arena<T>)

Prepends a new child to this node, before existing children.

§Panics

Panics if:

  • the given new child is self, or
  • the given new child is an ancestor of self, or
  • the current node or the given new child was already removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
let n1_1 = arena.new_node("1_1");
n1.prepend(n1_1, &mut arena);
let n1_2 = arena.new_node("1_2");
n1.prepend(n1_2, &mut arena);
let n1_3 = arena.new_node("1_3");
n1.prepend(n1_3, &mut arena);

// arena
// `-- 1
//     |-- 1_3
//     |-- 1_2
//     `-- 1_1

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), Some(n1_2));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), None);

pub fn checked_prepend<T>( self, new_child: NodeId, arena: &mut Arena<T>, ) -> Result<(), NodeError>

Prepends a new child to this node, before existing children.

§Failures
  • Returns NodeError::PrependSelf error if the given new child is self.
  • Returns [NodeError::PrependAncestor] error if the given new child is an ancestor of self.
  • Returns NodeError::Removed error if the given new child or self is removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
assert!(n1.checked_prepend(n1, &mut arena).is_err());

let n1_1 = arena.new_node("1_1");
assert!(n1.checked_prepend(n1_1, &mut arena).is_ok());

pub fn insert_after<T>(self, new_sibling: NodeId, arena: &mut Arena<T>)

Inserts a new sibling after this node.

§Panics

Panics if:

  • the given new sibling is self, or
  • the current node or the given new sibling was already removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
// arena
// `-- 1
//     |-- 1_1 *
//     `-- 1_2

let n1_3 = arena.new_node("1_3");
n1_1.insert_after(n1_3, &mut arena);

// arena
// `-- 1
//     |-- 1_1
//     |-- 1_3 *
//     `-- 1_2

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), Some(n1_2));
assert_eq!(iter.next(), None);

pub fn checked_insert_after<T>( self, new_sibling: NodeId, arena: &mut Arena<T>, ) -> Result<(), NodeError>

Inserts a new sibling after this node.

§Failures

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
assert!(n1.checked_insert_after(n1, &mut arena).is_err());

let n2 = arena.new_node("2");
assert!(n1.checked_insert_after(n2, &mut arena).is_ok());

pub fn insert_before<T>(self, new_sibling: NodeId, arena: &mut Arena<T>)

Inserts a new sibling before this node.

§Panics

Panics if:

  • the given new sibling is self, or
  • the current node or the given new sibling was already removed.

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
let n1_1 = arena.new_node("1_1");
n1.append(n1_1, &mut arena);
let n1_2 = arena.new_node("1_2");
n1.append(n1_2, &mut arena);

// arena
// `-- 1
//     |-- 1_1
//     `-- 1_2 *

let n1_3 = arena.new_node("1_3");
n1_2.insert_before(n1_3, &mut arena);

// arena
// `-- 1
//     |-- 1_1
//     |-- 1_3 *
//     `-- 1_2

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), Some(n1_2));
assert_eq!(iter.next(), None);

pub fn checked_insert_before<T>( self, new_sibling: NodeId, arena: &mut Arena<T>, ) -> Result<(), NodeError>

Inserts a new sibling before this node.

§Failures

To check if the node is removed or not, use Node::is_removed().

§Examples
let mut arena = Arena::new();
let n1 = arena.new_node("1");
assert!(n1.checked_insert_before(n1, &mut arena).is_err());

let n2 = arena.new_node("2");
assert!(n1.checked_insert_before(n2, &mut arena).is_ok());

pub fn remove<T>(self, arena: &mut Arena<T>)

Removes a node from the arena.

Children of the removed node will be inserted to the place where the removed node was.

Please note that the node will not be removed from the internal arena storage, but marked as removed. Traversing the arena returns a plain iterator and contains removed elements too.

To check if the node is removed or not, use Node::is_removed().

§Examples
// arena
// `-- 1
//     |-- 1_1
//     |-- 1_2 *
//     |   |-- 1_2_1
//     |   `-- 1_2_2
//     `-- 1_3

n1_2.remove(&mut arena);

// arena
// `-- 1
//     |-- 1_1
//     |-- 1_2_1
//     |-- 1_2_2
//     `-- 1_3

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_2_1));
assert_eq!(iter.next(), Some(n1_2_2));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), None);

pub fn remove_subtree<T>(self, arena: &mut Arena<T>)

Removes a node and its descendants from the arena.

§Examples
// arena
// `-- 1
//     |-- 1_1
//     |-- 1_2 *
//     |   |-- 1_2_1
//     |   `-- 1_2_2
//     `-- 1_3

n1_2.remove_subtree(&mut arena);

// arena
// `-- 1
//     |-- 1_1
//     `-- 1_3

let mut iter = n1.descendants(&arena);
assert_eq!(iter.next(), Some(n1));
assert_eq!(iter.next(), Some(n1_1));
assert_eq!(iter.next(), Some(n1_3));
assert_eq!(iter.next(), None);

pub fn debug_pretty_print<'a, T>( &'a self, arena: &'a Arena<T>, ) -> DebugPrettyPrint<'a, T>

Returns the pretty-printable proxy object to the node and descendants.

§(No) guarantees

This is provided mainly for debugging purpose. Node that the output format is not guaranteed to be stable, and any format changes won’t be considered as breaking changes.

§Examples

//  arena
//  `-- "root"
//      |-- "0"
//      |   |-- "0\n0"
//      |   `-- "0\n1"
//      |-- "1"
//      `-- "2"
//          `-- "2\n0"
//              `-- "2\n0\n0"

let printable = root.debug_pretty_print(&arena);

let expected_debug = r#""root"
|-- "0"
|   |-- "0\n0"
|   `-- "0\n1"
|-- "1"
`-- "2"
    `-- "2\n0"
        `-- "2\n0\n0""#;
assert_eq!(format!("{:?}", printable), expected_debug);

let expected_display = r#"root
|-- 0
|   |-- 0
|   |   0
|   `-- 0
|       1
|-- 1
`-- 2
    `-- 2
        0
        `-- 2
            0
            0"#;
assert_eq!(printable.to_string(), expected_display);

Alternate styles ({:#?} and {:#}) are also supported.


//  arena
//  `-- Ok(42)
//      `-- Err("err")

let printable = root.debug_pretty_print(&arena);

let expected_debug = r#"Ok(42)
`-- Err("err")"#;
assert_eq!(format!("{:?}", printable), expected_debug);

let expected_debug_alternate = r#"Ok(
    42,
)
`-- Err(
        "err",
    )"#;
assert_eq!(format!("{:#?}", printable), expected_debug_alternate);

Trait Implementations§

§

impl Clone for NodeId

§

fn clone(&self) -> NodeId

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for NodeId

§

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

Formats the value using the given formatter. Read more
§

impl Display for NodeId

§

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

Formats the value using the given formatter. Read more
§

impl Hash for NodeId

§

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

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
§

impl<T> Index<NodeId> for Arena<T>

§

type Output = Node<T>

The returned type after indexing.
§

fn index(&self, node: NodeId) -> &Node<T>

Performs the indexing (container[index]) operation. Read more
§

impl<T> IndexMut<NodeId> for Arena<T>

§

fn index_mut(&mut self, node: NodeId) -> &mut Node<T>

Performs the mutable indexing (container[index]) operation. Read more
§

impl Ord for NodeId

§

fn cmp(&self, other: &NodeId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for NodeId

§

fn eq(&self, other: &NodeId) -> 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.
§

impl PartialOrd for NodeId

§

fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Copy for NodeId

§

impl Eq for NodeId

§

impl StructuralPartialEq for NodeId

Auto Trait Implementations§

§

impl Freeze for NodeId

§

impl RefUnwindSafe for NodeId

§

impl Send for NodeId

§

impl Sync for NodeId

§

impl Unpin for NodeId

§

impl UnwindSafe for NodeId

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the concrete type as &dyn Any.
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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

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

§

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

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

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

§

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

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

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

§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,