docs

core::marker

On this page

Marker traits used by #[derive(..)] and other compiler-driven semantics. The comparison / hashing traits live in cmp.nabi.

Structs

HandoffSource

pub struct Handoff<T>

A value handed between threads under an outside protocol (a join, a lock, a channel hand-off) that keeps any two threads from using it at once: Send + Sync whenever the value is Send, even when it is not Sync (a collection). The toolchain's own: code elsewhere moves the value into the closure ([move x]) or hands it over.

  • pub const fn get(self) -> T§

    Source

    The wrapped value.

Trait implementations 3
  • impl<T> Debug for Handoff<T>
  • unsafe impl<T: Send> Send for Handoff<T>
  • unsafe impl<T: Send> Sync for Handoff<T>

Traits

CloneSource

pub trait Clone

An explicit duplicate: x.clone(); #[derive(Clone)] clones every field.

  • fn clone(self) -> Self§

    Source

    A copy of self; collections copy their elements.

DefaultSource

pub trait Default

A type's default value (0, false, '\0', "", empty collections); #[derive(Default)] defaults every field.

  • fn default() -> Self§

    Source

    The default value of Self.

CopySource

pub trait Copy: Clone

Bitwise copy is a correct duplicate. A marker: every value already copies on let y = x;; #[derive(Copy)] checks that every field is Copy and the type is not Drop.

DropSource

pub trait Drop

Cleanup on release. A Drop value has one owner: let b = a moves it, and the compiler calls drop where its owner leaves scope (on every exit, and when a task ends) or where a using block ends.

  • fn drop(ref self)§

    Source

    Releases what self holds; called once, where the value is released.

SendSource

pub trait Send

Safe to move to another thread.

SyncSource

pub trait Sync

Safe to read through shared references from several threads.

Type aliases

NoneSentinelSource

pub type NoneSentinel = none

The type of the none literal: the compiler's built-in none, here under its library name.

Functions

shareSource

pub unsafe fn share<T>(x: T) -> T

A second handle to x, which the compiler does not follow: it is neither moved nor released through it. The owner's rules still hold; using the handle after the owner released the value is the caller's to rule out.

replaceSource

pub fn replace<T>(ref dest: T, value: T) -> T

Put value into dest and return what it held: the way to move a part out of a struct (replace(ref s.part, none), as Child::take_stdout does).

takeSource

pub fn take<T: Default>(ref dest: T) -> T

replace(ref dest, T::default()).