Trait workflow_terminal::prelude::Deref

1.0.0 · source ·
pub trait Deref {
    type Target: ?Sized;

    // Required method
    fn deref(&self) -> &Self::Target;
}
Expand description

Used for immutable dereferencing operations, like *v.

In addition to being used for explicit dereferencing operations with the (unary) * operator in immutable contexts, Deref is also used implicitly by the compiler in many circumstances. This mechanism is called Deref coercion’. In mutable contexts, DerefMut is used.

Implementing Deref for smart pointers makes accessing the data behind them convenient, which is why they implement Deref. On the other hand, the rules regarding Deref and DerefMut were designed specifically to accommodate smart pointers. Because of this, Deref should only be implemented for smart pointers to avoid confusion.

For similar reasons, this trait should never fail. Failure during dereferencing can be extremely confusing when Deref is invoked implicitly.

Violating these requirements is a logic error. The behavior resulting from a logic error is not specified, but users of the trait must ensure that such logic errors do not result in undefined behavior. This means that unsafe code must not rely on the correctness of this method.

More on Deref coercion

If T implements Deref<Target = U>, and x is a value of type T, then:

  • In immutable contexts, *x (where T is neither a reference nor a raw pointer) is equivalent to *Deref::deref(&x).
  • Values of type &T are coerced to values of type &U
  • T implicitly implements all the (immutable) methods of the type U.

For more details, visit the chapter in The Rust Programming Language as well as the reference sections on the dereference operator, method resolution and type coercions.

Examples

A struct with a single field which is accessible by dereferencing the struct.

use std::ops::Deref;

struct DerefExample<T> {
    value: T
}

impl<T> Deref for DerefExample<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

let x = DerefExample { value: 'a' };
assert_eq!('a', *x);

Required Associated Types§

source

type Target: ?Sized

The resulting type after dereferencing.

Required Methods§

source

fn deref(&self) -> &Self::Target

Dereferences the value.

Implementors§

source§

impl Deref for FitAddon

source§

impl Deref for workflow_terminal::terminal::bindings::ResizeObserver

source§

impl Deref for WebLinksAddon

source§

impl Deref for XtermCoreImpl

source§

impl Deref for XtermEvent

source§

impl Deref for XtermImpl

source§

impl Deref for CString

§

type Target = CStr

source§

impl Deref for String

§

type Target = str

source§

impl Deref for OsString

source§

impl Deref for std::path::PathBuf

§

type Target = Path

source§

impl Deref for async_std::path::pathbuf::PathBuf

§

type Target = Path

source§

impl Deref for Collator

source§

impl Deref for DateTimeFormat

source§

impl Deref for NumberFormat

source§

impl Deref for PluralRules

source§

impl Deref for RelativeTimeFormat

source§

impl Deref for CompileError

source§

impl Deref for Global

source§

impl Deref for Instance

source§

impl Deref for LinkError

source§

impl Deref for Memory

source§

impl Deref for Module

source§

impl Deref for RuntimeError

source§

impl Deref for Table

source§

impl Deref for Array

source§

impl Deref for ArrayBuffer

source§

impl Deref for AsyncIterator

source§

impl Deref for BigInt64Array

source§

impl Deref for BigInt

source§

impl Deref for BigUint64Array

source§

impl Deref for Boolean

source§

impl Deref for DataView

source§

impl Deref for Date

source§

impl Deref for Error

source§

impl Deref for EvalError

source§

impl Deref for Float32Array

source§

impl Deref for Float64Array

source§

impl Deref for Function

source§

impl Deref for Generator

source§

impl Deref for Int8Array

source§

impl Deref for Int16Array

source§

impl Deref for Int32Array

source§

impl Deref for Iterator

source§

impl Deref for IteratorNext

source§

impl Deref for JsString

source§

impl Deref for Map

source§

impl Deref for Number

source§

impl Deref for Object

source§

impl Deref for Promise

source§

impl Deref for Proxy

source§

impl Deref for RangeError

source§

impl Deref for ReferenceError

source§

impl Deref for RegExp

source§

impl Deref for Set

source§

impl Deref for SharedArrayBuffer

source§

impl Deref for Symbol

source§

impl Deref for SyntaxError

source§

impl Deref for TypeError

source§

impl Deref for Uint8Array

source§

impl Deref for Uint8ClampedArray

source§

impl Deref for Uint16Array

source§

impl Deref for Uint32Array

source§

impl Deref for UriError

source§

impl Deref for WeakMap

source§

impl Deref for WeakSet

source§

impl Deref for Button

source§

impl Deref for Item

source§

impl Deref for nw_sys::chrome::notifications::Options

source§

impl Deref for Clipboard

source§

impl Deref for DataRead

source§

impl Deref for DataWrite

source§

impl Deref for MacOptions

source§

impl Deref for Menu

source§

impl Deref for nw_sys::menu::Options

source§

impl Deref for MenuItem

source§

impl Deref for nw_sys::menu_item::Options

source§

impl Deref for Nw

source§

impl Deref for nw_sys::shortcut::Options

source§

impl Deref for Shortcut

source§

impl Deref for nw_sys::tray::Options

source§

impl Deref for Tray

source§

impl Deref for CaptureConfig

source§

impl Deref for nw_sys::window::Options

source§

impl Deref for PrintOptions

source§

impl Deref for ScreenshotConfig

source§

impl Deref for nw_sys::window::Window

source§

impl Deref for Word<'_>

§

type Target = str

source§

impl Deref for Blob

source§

impl Deref for BlobPropertyBag

source§

impl Deref for CssStyleDeclaration

source§

impl Deref for CustomEvent

source§

impl Deref for DataTransfer

source§

impl Deref for Document

§

type Target = Node

source§

impl Deref for Element

§

type Target = Node

source§

impl Deref for Event

source§

impl Deref for EventTarget

source§

impl Deref for HtmlCollection

source§

impl Deref for HtmlElement

source§

impl Deref for HtmlIFrameElement

source§

impl Deref for KeyboardEvent

source§

impl Deref for Location

source§

impl Deref for MouseEvent

source§

impl Deref for Navigator

source§

impl Deref for Node

source§

impl Deref for NodeList

source§

impl Deref for web_sys::features::gen_ResizeObserver::ResizeObserver

source§

impl Deref for UiEvent

source§

impl Deref for Url

source§

impl Deref for web_sys::features::gen_Window::Window

§

impl Deref for Bytes

§

type Target = [u8]

§

impl Deref for BytesMut

§

type Target = [u8]

§

impl Deref for WakerRef<'_>

1.36.0 · source§

impl<'a> Deref for IoSlice<'a>

§

type Target = [u8]

1.36.0 · source§

impl<'a> Deref for IoSliceMut<'a>

§

type Target = [u8]

source§

impl<'a> Deref for MaybeUninitSlice<'a>

source§

impl<'a, 'f> Deref for VaList<'a, 'f>where 'f: 'a,

§

type Target = VaListImpl<'f>

§

impl<'a, R, G, T> Deref for MappedReentrantMutexGuard<'a, R, G, T>where R: RawMutex + 'a, G: GetThreadId + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, G, T> Deref for ReentrantMutexGuard<'a, R, G, T>where R: RawMutex + 'a, G: GetThreadId + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for MappedMutexGuard<'a, R, T>where R: RawMutex + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for MappedRwLockReadGuard<'a, R, T>where R: RawRwLock + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for MappedRwLockWriteGuard<'a, R, T>where R: RawRwLock + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for MutexGuard<'a, R, T>where R: RawMutex + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for RwLockReadGuard<'a, R, T>where R: RawRwLock + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for RwLockUpgradableReadGuard<'a, R, T>where R: RawRwLockUpgrade + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, R, T> Deref for RwLockWriteGuard<'a, R, T>where R: RawRwLock + 'a, T: 'a + ?Sized,

§

type Target = T

§

impl<'a, T> Deref for MappedMutexGuard<'a, T>where T: ?Sized,

§

type Target = T

§

impl<'a, T, F> Deref for PoolGuard<'a, T, F>where T: Send, F: Fn() -> T,

§

type Target = T

source§

impl<'s> Deref for SockRef<'s>

§

impl<A> Deref for SmallVec<A>where A: Array,

§

type Target = [<A as Array>::Item]

source§

impl<B> Deref for Cow<'_, B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Borrow<B>,

§

type Target = B

1.33.0 · source§

impl<P> Deref for Pin<P>where P: Deref,

§

type Target = <P as Deref>::Target

§

impl<S> Deref for BlockingStream<S>where S: Stream + Unpin,

§

type Target = S

source§

impl<T> Deref for &Twhere T: ?Sized,

§

type Target = T

source§

impl<T> Deref for &mut Twhere T: ?Sized,

§

type Target = T

source§

impl<T> Deref for ThinBox<T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for UniqueRc<T>

§

type Target = T

source§

impl<T> Deref for core::cell::Ref<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for RefMut<'_, T>where T: ?Sized,

§

type Target = T

1.20.0 · source§

impl<T> Deref for ManuallyDrop<T>where T: ?Sized,

§

type Target = T

1.9.0 · source§

impl<T> Deref for AssertUnwindSafe<T>

§

type Target = T

source§

impl<T> Deref for std::sync::mutex::MutexGuard<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for std::sync::rwlock::RwLockReadGuard<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for std::sync::rwlock::RwLockWriteGuard<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for Clamped<T>

§

type Target = T

source§

impl<T> Deref for JsStatic<T>where T: FromWasmAbi + 'static,

§

type Target = T

source§

impl<T> Deref for Sendable<T>

§

type Target = T

§

impl<T> Deref for CachePadded<T>

§

type Target = T

§

impl<T> Deref for MutexGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for MutexGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for MutexGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for MutexGuardArc<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for OwnedMutexGuard<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for OwnedMutexGuard<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for OwnedRwLockWriteGuard<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for Ref<'_, T>

§

type Target = T

§

impl<T> Deref for RwLockMappedWriteGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockReadGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockReadGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockReadGuardArc<T>

§

type Target = T

§

impl<T> Deref for RwLockUpgradableReadGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockUpgradableReadGuardArc<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockWriteGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockWriteGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for RwLockWriteGuardArc<T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for ShardedLockReadGuard<'_, T>where T: ?Sized,

§

type Target = T

§

impl<T> Deref for ShardedLockWriteGuard<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T, A> Deref for Box<T, A>where A: Allocator, T: ?Sized,

§

type Target = T

1.12.0 · source§

impl<T, A> Deref for PeekMut<'_, T, A>where T: Ord, A: Allocator,

§

type Target = T

source§

impl<T, A> Deref for Rc<T, A>where A: Allocator, T: ?Sized,

§

type Target = T

source§

impl<T, A> Deref for Arc<T, A>where A: Allocator, T: ?Sized,

§

type Target = T

source§

impl<T, A> Deref for Vec<T, A>where A: Allocator,

§

type Target = [T]

source§

impl<T, F> Deref for LazyCell<T, F>where F: FnOnce() -> T,

§

type Target = T

source§

impl<T, F> Deref for LazyLock<T, F>where F: FnOnce() -> T,

§

type Target = T

§

impl<T, F> Deref for Lazy<T, F>where F: Fn() -> T,

§

type Target = T

§

impl<T, F> Deref for Lazy<T, F>where F: FnOnce() -> T,

§

type Target = T

§

impl<T, F> Deref for Lazy<T, F>where F: FnOnce() -> T,

§

type Target = T

source§

impl<T, F, S> Deref for ScopeGuard<T, F, S>where F: FnOnce(T), S: Strategy,

§

type Target = T

§

impl<T, U> Deref for MappedMutexGuard<'_, T, U>where T: ?Sized, U: ?Sized,

§

type Target = U

§

impl<T, U> Deref for OwnedMappedMutexGuard<T, U>where T: ?Sized, U: ?Sized,

§

type Target = U

§

impl<T, U> Deref for OwnedRwLockMappedWriteGuard<T, U>where T: ?Sized, U: ?Sized,

§

type Target = U

§

impl<T, U> Deref for OwnedRwLockReadGuard<T, U>where T: ?Sized, U: ?Sized,

§

type Target = U

§

impl<Target> Deref for FilelikeView<'_, Target>where Target: FilelikeViewType,

§

type Target = Target

§

impl<Target> Deref for SocketlikeView<'_, Target>where Target: SocketlikeViewType,

§

type Target = Target