Trait druid::piet::cairo::glib::bitflags::_core::ops::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.

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§

§

impl Deref for StrokeDash

§

type Target = [f64]

§

impl Deref for Gradient

§

impl Deref for ImageSurface

§

impl Deref for ImageSurfaceDataOwned

§

type Target = [u8]

§

impl Deref for druid::piet::cairo::LinearGradient

§

impl Deref for MappedImageSurface

§

impl Deref for Mesh

§

impl Deref for druid::piet::cairo::RadialGradient

§

impl Deref for RecordingSurface

§

impl Deref for RectangleList

§

impl Deref for SolidPattern

§

impl Deref for SurfacePattern

§

impl Deref for UserFontFace

§

impl Deref for XCBSurface

§

impl Deref for BoxedValue

§

impl Deref for ByteArray

§

type Target = [u8]

§

impl Deref for Bytes

§

type Target = [u8]

§

impl Deref for GStr

§

type Target = str

§

impl Deref for GString

§

type Target = str

§

impl Deref for GStringBuilder

§

type Target = str

§

impl Deref for ILong

§

type Target = i64

§

impl Deref for ParamSpecBoolean

§

impl Deref for ParamSpecBoxed

§

impl Deref for ParamSpecChar

§

impl Deref for ParamSpecDouble

§

impl Deref for ParamSpecEnum

§

impl Deref for ParamSpecFlags

§

impl Deref for ParamSpecFloat

§

impl Deref for ParamSpecGType

§

impl Deref for ParamSpecInt64

§

impl Deref for ParamSpecInt

§

impl Deref for ParamSpecLong

§

impl Deref for ParamSpecObject

§

impl Deref for ParamSpecOverride

§

impl Deref for ParamSpecParam

§

impl Deref for ParamSpecPointer

§

impl Deref for ParamSpecString

§

impl Deref for ParamSpecUChar

§

impl Deref for ParamSpecUInt64

§

impl Deref for ParamSpecUInt

§

impl Deref for ParamSpecULong

§

impl Deref for ParamSpecUnichar

§

impl Deref for ParamSpecValueArray

§

impl Deref for ParamSpecVariant

§

impl Deref for SendValue

§

impl Deref for ULong

§

type Target = u64

§

impl Deref for ValueArray

§

type Target = [Value]

§

impl Deref for VariantType

§

impl Deref for ObjectPath

§

type Target = str

§

impl Deref for Signature

§

type Target = str

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 PathBuf

§

type Target = Path

source§

impl Deref for Error

§

type Target = dyn Error + Sync + Send + 'static

source§

impl Deref for EnteredSpan

§

type Target = Span

source§

impl Deref for usvg::paint_server::LinearGradient

source§

impl Deref for usvg::paint_server::RadialGradient

§

impl Deref for ArgumentList

§

impl Deref for AttrColor

§

type Target = Attribute

§

impl Deref for AttrFloat

§

type Target = Attribute

§

impl Deref for AttrFontDesc

§

type Target = Attribute

§

impl Deref for AttrFontFeatures

§

type Target = Attribute

§

impl Deref for AttrInt

§

type Target = Attribute

§

impl Deref for AttrLanguage

§

type Target = Attribute

§

impl Deref for AttrShape

§

type Target = Attribute

§

impl Deref for AttrSize

§

type Target = Attribute

§

impl Deref for AttrString

§

type Target = Attribute

§

impl Deref for Border

§

type Target = GtkBorder

§

impl Deref for EventButton

§

type Target = Event

§

impl Deref for EventConfigure

§

type Target = Event

§

impl Deref for EventCrossing

§

type Target = Event

§

impl Deref for EventDND

§

type Target = Event

§

impl Deref for EventExpose

§

type Target = Event

§

impl Deref for EventFocus

§

type Target = Event

§

impl Deref for EventGrabBroken

§

type Target = Event

§

impl Deref for EventKey

§

type Target = Event

§

impl Deref for EventMotion

§

type Target = Event

§

impl Deref for EventOwnerChange

§

type Target = Event

§

impl Deref for EventPadAxis

§

type Target = Event

§

impl Deref for EventPadButton

§

type Target = Event

§

impl Deref for EventPadGroupMode

§

type Target = Event

§

impl Deref for EventProperty

§

type Target = Event

§

impl Deref for EventProximity

§

type Target = Event

§

impl Deref for EventScroll

§

type Target = Event

§

impl Deref for EventSelection

§

type Target = Event

§

impl Deref for EventSetting

§

type Target = Event

§

impl Deref for EventTouch

§

type Target = Event

§

impl Deref for EventTouchpadPinch

§

type Target = Event

§

impl Deref for EventTouchpadSwipe

§

type Target = Event

§

impl Deref for EventVisibility

§

type Target = Event

§

impl Deref for EventWindowState

§

type Target = Event

§

impl Deref for Key

§

type Target = u32

§

impl Deref for Literal

§

impl Deref for Mmap

§

type Target = [u8]

§

impl Deref for MmapMut

§

type Target = [u8]

§

impl Deref for StringStorage<'_>

§

type Target = str

§

impl Deref for WakerRef<'_>

§

impl Deref for dyn TextStorage + 'static

§

type Target = str

§

impl<'a> Deref for ImageSurfaceData<'a>

§

type Target = [u8]

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]

§

impl<'a> Deref for Face<'a>

§

type Target = Face<'a>

§

impl<'a> Deref for StrSpan<'a>

§

type Target = str

§

impl<'a> Deref for Subtable1<'a>

§

type Target = ExtendedStateTable<'a, EntryData>

§

impl<'a> Deref for Subtable4<'a>

§

type Target = ExtendedStateTable<'a, EntryData>

source§

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

§

type Target = VaListImpl<'f>

§

impl<'a, T> Deref for ClassRef<'a, T>where T: IsClass,

§

type Target = Class<T>

§

impl<'a, T> Deref for InterfaceRef<'a, T>where T: IsInterface,

§

impl<'a, T> Deref for BorrowedObject<'a, T>

§

type Target = T

source§

impl<'a, T, C> Deref for sharded_slab::pool::Ref<'a, T, C>where T: Clear + Default, C: Config,

§

type Target = T

source§

impl<'a, T, C> Deref for sharded_slab::pool::RefMut<'a, T, C>where C: Config, T: Clear + Default,

§

type Target = T

source§

impl<'a, T, C> Deref for Entry<'a, T, C>where C: Config,

§

type Target = T

source§

impl<'c> Deref for PaintCtx<'_, '_, 'c>

§

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

§

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

§

impl<A, N> Deref for Chunk<A, N>where N: ChunkLength<A>,

§

type Target = [A]

§

impl<A, T> Deref for FixedSizeVariantArray<A, T>where A: AsRef<[T]>, T: FixedSizeVariantType,

§

type Target = A

§

impl<A, T> Deref for InlineArray<A, T>

§

type Target = [A]

const: unstable · source§

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

§

type Target = B

source§

impl<E> Deref for FormattedFields<E>where E: ?Sized,

§

impl<I> Deref for SubImage<I>where I: Deref,

§

type Target = SubImageInner<I>

1.33.0 · source§

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

§

type Target = <P as Deref>::Target

§

impl<P, Container> Deref for ImageBuffer<P, Container>where P: Pixel, Container: Deref<Target = [<P as Pixel>::Subpixel]>,

§

type Target = [<P as Pixel>::Subpixel]

§

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

§

type Target = S

const: unstable · source§

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

§

type Target = T

const: unstable · source§

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

§

type Target = T

source§

impl<T> Deref for Label<T>

§

impl<T> Deref for Class<T>where T: ParentClassIs,

§

impl<T> Deref for PtrSlice<T>where T: GlibPtrDefault + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType> + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType>,

§

type Target = [T]

§

impl<T> Deref for SendWeakRef<T>where T: ObjectType,

§

type Target = WeakRef<T>

§

impl<T> Deref for Slice<T>where T: 'static,

§

type Target = [T]

§

impl<T> Deref for ClassStruct<T>where T: ObjectSubclass,

§

impl<T> Deref for ObjectImplRef<T>where T: ObjectSubclass,

§

type Target = T

§

impl<T> Deref for Borrowed<T>

§

type Target = T

source§

impl<T> Deref for druid::piet::cairo::glib::bitflags::_core::cell::Ref<'_, T>where T: ?Sized,

§

type Target = T

source§

impl<T> Deref for druid::piet::cairo::glib::bitflags::_core::cell::RefMut<'_, T>where T: ?Sized,

§

type Target = T

1.20.0 (const: unstable) · 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 ThinBox<T>where T: ?Sized,

§

type Target = T

1.12.0 · source§

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

§

type Target = T

source§

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

§

type Target = T

source§

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

§

type Target = T

source§

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

§

type Target = T

source§

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

§

type Target = T

source§

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

§

type Target = T

§

impl<T> Deref for Gray<T>

§

type Target = T

§

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

§

type Target = T

§

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

§

type Target = T

§

impl<T> Deref for TemplateChild<T>where T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,

§

type Target = T

const: unstable · source§

impl<T, A> Deref for Box<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, C> Deref for OwnedRef<T, C>where T: Clear + Default, C: Config,

§

type Target = T

source§

impl<T, C> Deref for OwnedRefMut<T, C>where T: Clear + Default, C: Config,

§

type Target = T

source§

impl<T, C> Deref for OwnedEntry<T, C>where C: Config,

§

type Target = T

§

impl<T, F> Deref for druid::piet::cairo::glib::once_cell::sync::Lazy<T, F>where F: FnOnce() -> T,

§

type Target = T

§

impl<T, F> Deref for druid::piet::cairo::glib::once_cell::unsync::Lazy<T, F>where F: FnOnce() -> T,

§

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, MM> Deref for Boxed<T, MM>where T: 'static, MM: BoxedMemoryManager<T>,

§

type Target = T

§

impl<T, P> Deref for TypedObjectRef<T, P>

§

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

§

type Target = U

source§

impl<T, const CAP: usize> Deref for ArrayVec<T, CAP>

§

type Target = [T]

source§

impl<const CAP: usize> Deref for ArrayString<CAP>

§

type Target = str

§

impl<const N: usize> Deref for TinyAsciiStr<N>

§

type Target = str