pub struct WeakPtr<T: ?Sized> { /* private fields */ }Expand description
Represents a pointer that only references the data it’s pointing to.
Unlike OwnedPtr, dropping this pointer has no effect on the underlying data, this pointer can only immutably
access the underlying data, and care must be taken to prevent this pointer from dangling.
This can be used in conjunction with OwnedPtr to form complex (and sometimes cyclic) data structures while
still adhering to Rust’s ownership rules, and avoiding un-droppable memory cycles.
Implementations§
Trait Implementations§
Source§impl<'a, T: ?Sized, U: ?Sized> PartialEq<&'a T> for WeakPtr<U>
impl<'a, T: ?Sized, U: ?Sized> PartialEq<&'a T> for WeakPtr<U>
Source§fn eq(&self, other: &&'a T) -> bool
fn eq(&self, other: &&'a T) -> bool
Returns true if this pointer and the provided reference both point to the same memory address.
Note that this may return true in some unintuitive/exotic cases:
- If you have 2 references to the same piece of data, with different types, this will return true. For example,
comparing
Stringtodyn Displayis valid, and will return true if they’re actually the same. - If one or both of the types are zero-sized: since it’s address may overlap with another piece of data.
- Comparing the address of a struct to the address of its first field: these are conceptually different things, but both live at the same address, since structs are stored as a list of it’s fields.
See https://doc.rust-lang.org/std/ptr/fn.eq.html for more information. This function uses the same semantics.
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Attribute>
impl<'a> TryFrom<&'a Node> for WeakPtr<Attribute>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Attribute>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Attribute>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Class>
impl<'a> TryFrom<&'a Node> for WeakPtr<Class>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Class>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Class>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<CustomType>
impl<'a> TryFrom<&'a Node> for WeakPtr<CustomType>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<CustomType>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<CustomType>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Dictionary>
impl<'a> TryFrom<&'a Node> for WeakPtr<Dictionary>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Dictionary>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Dictionary>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Enum>
impl<'a> TryFrom<&'a Node> for WeakPtr<Enum>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Enum>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Enum>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Enumerator>
impl<'a> TryFrom<&'a Node> for WeakPtr<Enumerator>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Enumerator>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Enumerator>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Exception>
impl<'a> TryFrom<&'a Node> for WeakPtr<Exception>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Exception>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Exception>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Field>
impl<'a> TryFrom<&'a Node> for WeakPtr<Field>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Field>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Field>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Interface>
impl<'a> TryFrom<&'a Node> for WeakPtr<Interface>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Interface>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Interface>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Module>
impl<'a> TryFrom<&'a Node> for WeakPtr<Module>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Module>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Module>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Operation>
impl<'a> TryFrom<&'a Node> for WeakPtr<Operation>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Operation>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Operation>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Parameter>
impl<'a> TryFrom<&'a Node> for WeakPtr<Parameter>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Parameter>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Parameter>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Primitive>
impl<'a> TryFrom<&'a Node> for WeakPtr<Primitive>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Primitive>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Primitive>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<ResultType>
impl<'a> TryFrom<&'a Node> for WeakPtr<ResultType>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<ResultType>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<ResultType>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Sequence>
impl<'a> TryFrom<&'a Node> for WeakPtr<Sequence>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Sequence>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Sequence>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<Struct>
impl<'a> TryFrom<&'a Node> for WeakPtr<Struct>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<Struct>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<Struct>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.
Source§type Error = LookupError
type Error = LookupError
Source§impl<'a> TryFrom<&'a Node> for WeakPtr<TypeAlias>
impl<'a> TryFrom<&'a Node> for WeakPtr<TypeAlias>
Source§fn try_from(node: &'a Node) -> Result<WeakPtr<TypeAlias>, Self::Error>
fn try_from(node: &'a Node) -> Result<WeakPtr<TypeAlias>, Self::Error>
Attempts to unwrap a node to the specified concrete type.
If the Slice element held by the node is the specified type, this succeeds, and returns the unwrapped element in the requested container. Otherwise this method fails and returns an error message.