RawEntityRef

Struct RawEntityRef 

Source
pub struct RawEntityRef<T: ?Sized, Metadata = ()> { /* private fields */ }
Expand description

A RawEntityRef is an unsafe smart pointer type for IR entities allocated in a [Context].

Along with the type of entity referenced, it can be instantiated with extra metadata of any type. For example, UnsafeIntrusiveEntityRef stores an intrusive link in the entity metadata, so that the entity can be added to an intrusive linked list without the entity needing to know about the link - and without violating aliasing rules when navigating the list.

Unlike regular references, no reference to the underlying T is constructed until one is needed, at which point the borrow (whether mutable or immutable) is dynamically checked to ensure that it is valid according to Rust’s aliasing rules.

As a result, a RawEntityRef is not considered an alias, and it is possible to acquire a mutable reference to the underlying data even while other copies of the handle exist. Any attempt to construct invalid aliases (immutable reference while a mutable reference exists, or vice versa), will result in a runtime panic.

This is a tradeoff, as we do not get compile-time guarantees that such panics will not occur, but in exchange we get a much more flexible and powerful IR structure.

§SAFETY

Unlike most smart-pointer types, e.g. Rc, [RAwEntityRef] does not provide any protection against the underlying allocation being deallocated (i.e. the arena it points into is dropped). This is by design, as the type is meant to be stored in objects inside the arena, and not dropped when the arena is dropped. This requires care when using it however, to ensure that no RawEntityRef lives longer than the arena that allocated it.

For a safe entity reference, see EntityRef, which binds a RawEntityRef to the lifetime of the arena.

Implementations§

Source§

impl<T: 'static> RawEntityRef<T, IntrusiveLink>

Source

pub fn new(value: T, arena: &Blink) -> Self

Create a new UnsafeIntrusiveEntityRef by allocating value in arena

§SAFETY

This function has the same requirements around safety as RawEntityRef::new.

Source

pub fn new_uninit(arena: &Blink) -> RawEntityRef<MaybeUninit<T>, IntrusiveLink>

Source§

impl<T> RawEntityRef<T, IntrusiveLink>

Source

pub fn parent( &self, ) -> Option<UnsafeIntrusiveEntityRef<<T as EntityWithParent>::Parent>>

Returns the parent entity this entity is linked to, if linked.

Source§

impl<T> RawEntityRef<T, IntrusiveLink>

Source§

impl<T> RawEntityRef<T, IntrusiveLink>

Source

pub fn is_linked(&self) -> bool

Returns true if this entity is linked into an intrusive list

Source

pub fn prev(&self) -> Option<Self>

Get the previous entity in the list of T containing the current entity

For example, in a list of Operation in a Block, this would return the handle of the previous operation in the block, or None if there are no other ops before this one.

Source

pub fn next(&self) -> Option<Self>

Get the next entity in the list of T containing the current entity

For example, in a list of Operation in a Block, this would return the handle of the next operation in the block, or None if there are no other ops after this one.

Source§

impl<T: 'static, Metadata: 'static> RawEntityRef<T, Metadata>

Source

pub fn new_with_metadata(value: T, metadata: Metadata, arena: &Blink) -> Self

Create a new RawEntityRef by allocating value with metadata in the given arena allocator.

§SAFETY

The resulting RawEntityRef must not outlive the arena. This is not enforced statically, it is up to the caller to uphold the invariants of this type.

Source

pub fn new_uninit_with_metadata( metadata: Metadata, arena: &Blink, ) -> RawEntityRef<MaybeUninit<T>, Metadata>

Create a RawEntityRef for an entity which may not be fully initialized, using the provided arena.

§SAFETY

The safety rules are much the same as RawEntityRef::new, with the main difference being that the T does not have to be initialized yet. No references to the T will be created directly until RawEntityRef::assume_init is called.

Source§

impl<T: 'static> RawEntityRef<T, ()>

Source

pub fn new(value: T, arena: &Blink) -> Self

Source

pub fn new_uninit(arena: &Blink) -> RawEntityRef<MaybeUninit<T>, ()>

Source§

impl<T, Metadata> RawEntityRef<MaybeUninit<T>, Metadata>

Source

pub unsafe fn assume_init(self) -> RawEntityRef<T, Metadata>

Converts to RawEntityRef<T>.

§Safety

Just like with MaybeUninit::assume_init, it is up to the caller to guarantee that the value really is in an initialized state. Calling this when the content is not yet fully initialized causes immediate undefined behavior.

Source§

impl<T: ?Sized, Metadata> RawEntityRef<T, Metadata>

Source

pub fn into_raw(this: Self) -> *const T

Convert this handle into a raw pointer to the underlying entity.

This should only be used in situations where the returned pointer will not be used to actually access the underlying entity. Use [get] or [get_mut] for that. RawEntityRef ensures that Rust’s aliasing rules are not violated when using it, but if you use the returned pointer to do so, no such guarantee is provided, and undefined behavior can result.

§Safety

The returned pointer must not be used to create a reference to the underlying entity unless you can guarantee that such a reference does not violate Rust’s aliasing rules.

Do not use the pointer to create a mutable reference if other references exist, and do not use the pointer to create an immutable reference if a mutable reference exists or might be created while the immutable reference lives.

Source

pub fn as_ptr(this: &Self) -> *const T

Source

pub unsafe fn from_raw(ptr: *const T) -> Self

Convert a pointer returned by RawEntityRef::into_raw back into a RawEntityRef.

§Safety
  • It is only valid to call this method on a pointer returned by RawEntityRef::into_raw.
  • The pointer must be a valid pointer for T
Source

pub fn borrow<'a, 'b: 'a>(&'a self) -> EntityRef<'b, T>

Get a dynamically-checked immutable reference to the underlying T

Source

pub fn borrow_mut<'a, 'b: 'a>(&'a mut self) -> EntityMut<'b, T>

Get a dynamically-checked mutable reference to the underlying T

Source

pub fn try_borrow_mut<'a, 'b: 'a>(&'a mut self) -> Option<EntityMut<'b, T>>

Try to get a dynamically-checked mutable reference to the underlying T

Returns None if the entity is already borrowed

Source

pub fn ptr_eq(this: &Self, other: &Self) -> bool

Source§

impl<From: ?Sized, Metadata: 'static> RawEntityRef<From, Metadata>

Source

pub fn try_downcast<To>( self, ) -> Result<RawEntityRef<To, Metadata>, RawEntityRef<From, Metadata>>
where To: DowncastFromRef<From> + 'static, From: 'static,

Casts this reference to the concrete type T, if the underlying value is a T.

If the cast is not valid for this reference, Err is returned containing the original value.

Source

pub fn try_downcast_ref<To, Obj>(&self) -> Option<RawEntityRef<To, Metadata>>
where To: DowncastFromRef<From> + 'static, From: Is<Obj> + AsAny + 'static, Obj: ?Sized,

Casts this reference to the concrete type T, if the underlying value is a T.

If the cast is not valid for this reference, Err is returned containing the original value.

Source

pub fn downcast<To, Obj>(self) -> RawEntityRef<To, Metadata>
where To: DowncastFromRef<From> + 'static, From: Is<Obj> + AsAny + 'static, Obj: ?Sized,

Casts this reference to the concrete type T, if the underlying value is a T.

Panics if the cast is not valid for this reference.

Source

pub fn downcast_ref<To, Obj>(&self) -> RawEntityRef<To, Metadata>
where To: DowncastFromRef<From> + 'static, From: Is<Obj> + AsAny + 'static, Obj: ?Sized,

Casts this reference to the concrete type T, if the underlying value is a T.

Panics if the cast is not valid for this reference.

Source§

impl<To, Metadata: 'static> RawEntityRef<To, Metadata>

Source

pub fn try_downcast_from<From>( from: RawEntityRef<From, Metadata>, ) -> Result<Self, RawEntityRef<From, Metadata>>
where From: ?Sized + 'static, To: DowncastFromRef<From> + 'static,

Source

pub fn try_downcast_from_ref<From, Obj>( from: &RawEntityRef<From, Metadata>, ) -> Option<Self>
where From: ?Sized + Is<Obj> + AsAny + 'static, To: DowncastFromRef<From> + 'static, Obj: ?Sized,

Source

pub fn downcast_from<From, Obj>(from: RawEntityRef<From, Metadata>) -> Self
where From: ?Sized + Is<Obj> + AsAny + 'static, To: DowncastFromRef<From> + 'static, Obj: ?Sized,

Source

pub fn downcast_from_ref<From, Obj>(from: &RawEntityRef<From, Metadata>) -> Self
where From: ?Sized + Is<Obj> + AsAny + 'static, To: DowncastFromRef<From> + 'static, Obj: ?Sized,

Source§

impl<From: ?Sized, Metadata: 'static> RawEntityRef<From, Metadata>

Source

pub fn upcast<To>(self) -> RawEntityRef<To, Metadata>
where To: ?Sized, From: Unsize<To> + AsAny + 'static,

Casts this reference to the an unsized type Trait, if From implements Trait

If the cast is not valid for this reference, Err is returned containing the original value.

Source§

impl<T: Op> RawEntityRef<T, IntrusiveLink>

Source

pub fn as_operation_ref(self) -> OperationRef

Get a entity ref for the underlying crate::Operation data of an [Op].

Source§

impl RawEntityRef<Operation, IntrusiveLink>

Insertion

Source

pub fn insert_at_start(self, block: BlockRef)

Source

pub fn insert_at_end(self, block: BlockRef)

Source

pub fn insert_before(self, before: OperationRef)

Source

pub fn insert_after(self, after: OperationRef)

Source§

impl RawEntityRef<Operation, IntrusiveLink>

Read-only Metadata

Source

pub fn name(&self) -> OperationName

Source

pub fn parent_op(&self) -> Option<OperationRef>

Returns a handle to the nearest containing Operation of this operation, if it is attached to one

Source

pub fn parent_region(&self) -> Option<RegionRef>

Returns a handle to the containing Region of this operation, if it is attached to one

Source

pub fn nearest_symbol_table(&self) -> Option<OperationRef>

Returns the nearest SymbolTable from this operation.

Returns None if no parent of this operation is a valid symbol table.

Trait Implementations§

Source§

impl Borrow<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for &ValueOrAlias

Source§

fn borrow(&self) -> &ValueRef

Immutably borrows from an owned value. Read more
Source§

impl Borrow<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for &mut ValueOrAlias

Source§

fn borrow(&self) -> &ValueRef

Immutably borrows from an owned value. Read more
Source§

impl Borrow<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for ValueOrAlias

Source§

fn borrow(&self) -> &ValueRef

Immutably borrows from an owned value. Read more
Source§

impl<T: ?Sized, Metadata> Clone for RawEntityRef<T, Metadata>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized + Debug, Metadata> Debug for RawEntityRef<T, Metadata>

Source§

default fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + Debug + EntityWithId, Metadata> Debug for RawEntityRef<T, Metadata>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + Display, Metadata> Display for RawEntityRef<T, Metadata>

Source§

default fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + Display + EntityWithId, Metadata> Display for RawEntityRef<T, Metadata>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<RawEntityRef<Block, IntrusiveLink>> for ProgramPoint

Construct a ProgramPoint referring to the point at entry to block

Source§

fn from(block: BlockRef) -> Self

Converts to this type from the input type.
Source§

impl From<RawEntityRef<Operation, IntrusiveLink>> for ProgramPoint

Construct a ProgramPoint referring to the point at entry to op

Source§

fn from(op: OperationRef) -> Self

Converts to this type from the input type.
Source§

impl From<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for Callable

Source§

fn from(value: ValueRef) -> Self

Converts to this type from the input type.
Source§

impl From<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for ValueOrAlias

Source§

fn from(value: ValueRef) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> FromIterator<RawEntityRef<BlockArgument>> for ValueRange<'static, N>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = BlockArgumentRef>,

Creates a value from an iterator. Read more
Source§

impl<const N: usize> FromIterator<RawEntityRef<OpOperandImpl, IntrusiveLink>> for ValueRange<'static, N>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = OpOperand>,

Creates a value from an iterator. Read more
Source§

impl<const N: usize> FromIterator<RawEntityRef<OpResult>> for ValueRange<'static, N>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = OpResultRef>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<RawEntityRef<SymbolUse, IntrusiveLink>> for SymbolUseRefsIter

Source§

fn from_iter<T: IntoIterator<Item = SymbolUseRef>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<RawEntityRef<SymbolUse, IntrusiveLink>> for SymbolUsesIter

Source§

fn from_iter<T: IntoIterator<Item = SymbolUseRef>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: EntityListItem> FromIterator<RawEntityRef<T, IntrusiveLink>> for EntityList<T>

Source§

fn from_iter<I>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<const N: usize> FromIterator<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for ValueRange<'static, N>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = ValueRef>,

Creates a value from an iterator. Read more
Source§

impl<T: ?Sized, Metadata> Hash for RawEntityRef<T, Metadata>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: ?Sized + EntityWithId, Metadata> Ord for RawEntityRef<T, Metadata>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<RawEntityRef<dyn Value<Id = ValueId, Use = OpOperandImpl>>> for ValueOrAlias

Source§

fn eq(&self, other: &ValueRef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ?Sized, Metadata> PartialEq for RawEntityRef<T, Metadata>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ?Sized + EntityWithId, Metadata> PartialOrd for RawEntityRef<T, Metadata>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: ?Sized, Metadata> Pointer for RawEntityRef<T, Metadata>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + PrettyPrint, Metadata> PrettyPrint for RawEntityRef<T, Metadata>

Source§

fn render(&self) -> Document

The core of the PrettyPrint functionality. Read more
Source§

fn to_pretty_string(&self) -> String

Produce a String containing the results of pretty-printing this object. Read more
Source§

fn pretty_print(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Pretty-print this object to the given core::fmt::Formatter. Read more
Source§

impl<T: ?Sized + Spanned, Metadata> Spanned for RawEntityRef<T, Metadata>

Source§

impl<T: ?Sized + StorableEntity, Metadata> StorableEntity for RawEntityRef<T, Metadata>

Source§

fn index(&self) -> usize

Get the absolute index of this entity in its container.
Source§

unsafe fn set_index(&mut self, index: usize)

Set the absolute index of this entity in its container. Read more
Called when this entity is removed from EntityStorage
Source§

impl<T, U, Metadata> CoerceUnsized<RawEntityRef<U, Metadata>> for RawEntityRef<T, Metadata>
where T: ?Sized + Unsize<U>, U: ?Sized,

Source§

impl<T: ?Sized, Metadata> Copy for RawEntityRef<T, Metadata>

Source§

impl<T: ?Sized, Metadata> Eq for RawEntityRef<T, Metadata>

Auto Trait Implementations§

§

impl<T, Metadata> Freeze for RawEntityRef<T, Metadata>
where T: ?Sized,

§

impl<T, Metadata = ()> !RefUnwindSafe for RawEntityRef<T, Metadata>

§

impl<T, Metadata = ()> !Send for RawEntityRef<T, Metadata>

§

impl<T, Metadata = ()> !Sync for RawEntityRef<T, Metadata>

§

impl<T, Metadata> Unpin for RawEntityRef<T, Metadata>
where T: ?Sized,

§

impl<T, Metadata = ()> !UnwindSafe for RawEntityRef<T, Metadata>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<H> DynHash for H
where H: Hash,

Source§

fn dyn_hash(&self, hasher: &mut dyn Hasher)

Source§

impl<T> DynPartialEq for T
where T: PartialEq + 'static,

Source§

default fn dyn_eq(&self, rhs: &(dyn DynPartialEq + 'static)) -> bool

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> PassTarget for T
where T: 'static,

Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, Trait> Verifier<Trait> for T
where Trait: ?Sized,

Source§

const VACUOUS: bool = true

An implementation of Verifier sets this flag to true when its implementation is vacuous, i.e. it always succeeds and is not dependent on runtime context. Read more
Source§

default fn should_verify(&self, _context: &Context) -> bool

Checks if this verifier is applicable for the current item
Source§

default fn maybe_verify(&self, _context: &Context) -> Result<(), Report>

Applies the verifier for this item, if Verifier::should_verify returns true
Source§

default fn verify(&self, _context: &Context) -> Result<(), Report>

Applies the verifier for this item
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more