basedrop

Struct Node

Source
#[repr(C)]
pub struct Node<T> { pub data: T, /* private fields */ }
Expand description

An allocation that can be added to its associated Collector’s drop queue.

Node provides a low-level interface intended for use in the implementation of smart pointers and data structure internals. It is used in the implementations of Owned and Shared.

Fields§

§data: T

The data stored in this allocation.

Implementations§

Source§

impl<T: Send + 'static> Node<T>

Source

pub fn alloc(handle: &Handle, data: T) -> *mut Node<T>

Allocates a Node with the given data. Note that the Node will not be added to the drop queue or freed unless queue_drop is called.

§Examples
use basedrop::{Collector, Handle, Node};

let mut collector = Collector::new();
let handle = collector.handle();
let node = Node::alloc(&handle, 3);
Source§

impl<T> Node<T>

Source

pub unsafe fn queue_drop(node: *mut Node<T>)

Adds a Node to its associated Collector’s drop queue. The Node and its contained data may be dropped at a later time when Collector::collect or Collector::collect_one is called.

The argument must point to a valid Node previously allocated with Node::alloc. queue_drop may only be called once for a given Node, and the Node’s data must not be accessed afterwards.

§Examples
use basedrop::{Collector, Handle, Node};

let mut collector = Collector::new();
let handle = collector.handle();
let node = Node::alloc(&handle, 3);

unsafe {
    Node::queue_drop(node);
}
Source

pub unsafe fn handle(node: *mut Node<T>) -> Handle

Gets a Handle to this Node’s associated Collector.

The argument must point to a valid Node previously allocated with Node::alloc, on which queue_drop has not been called.

Auto Trait Implementations§

§

impl<T> !Freeze for Node<T>

§

impl<T> RefUnwindSafe for Node<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Node<T>

§

impl<T> !Sync for Node<T>

§

impl<T> Unpin for Node<T>
where T: Unpin,

§

impl<T> UnwindSafe for Node<T>
where 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> 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, 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.