Trait variadics::EitherRefVariadic
source · pub trait EitherRefVariadic: VariadicExt + Sealed {
type UnRefVar: VariadicExt;
type RefVar: RefVariadic<UnRefVar = Self::UnRefVar, RefVar = Self::RefVar>;
type MutVar: MutVariadic<UnRefVar = Self::UnRefVar, MutVar = Self::MutVar>;
// Required methods
fn mut_to_ref(self) -> Self::RefVar;
fn unref_ref(&self) -> <Self::UnRefVar as VariadicExt>::AsRefVar<'_>;
}
Expand description
A variadic of either shared references, exclusive references, or both.
Provides the Self::UnRefVar
associated type which is the original variadic of owned values.
This is a sealed trait.
Required Associated Types§
sourcetype UnRefVar: VariadicExt
type UnRefVar: VariadicExt
The un-referenced variadic. Each item will have one layer of shared references removed.
The inverse of VariadicExt::AsRefVar
and VariadicExt::AsMutVar
.
let un_ref: <var_type!(&u32, &String, &bool) as EitherRefVariadic>::UnRefVar =
var_expr!(1_u32, "Hello".to_owned(), false);
sourcetype RefVar: RefVariadic<UnRefVar = Self::UnRefVar, RefVar = Self::RefVar>
type RefVar: RefVariadic<UnRefVar = Self::UnRefVar, RefVar = Self::RefVar>
This type with all exclusive &mut
references replaced with shared &
references.
Returned by Self::mut_to_ref
.
sourcetype MutVar: MutVariadic<UnRefVar = Self::UnRefVar, MutVar = Self::MutVar>
type MutVar: MutVariadic<UnRefVar = Self::UnRefVar, MutVar = Self::MutVar>
This type with all shared &
references replaced with exclusive references &mut
.
Conversion from &
to &mut
is generally invalid, so a ref_to_mut()
method does not exist.
Required Methods§
sourcefn mut_to_ref(self) -> Self::RefVar
fn mut_to_ref(self) -> Self::RefVar
Convert all exclusive (mut
) references into shared references: RefVariadic
.
let mut original = var_expr!(1_u32, "Hello".to_owned(), false);
let as_mut: var_type!(&mut u32, &mut String, &mut bool) = original.as_mut_var();
let as_ref_1: var_type!(&u32, &String, &bool) = as_mut.mut_to_ref();
let as_ref_2: var_type!(&u32, &String, &bool) = as_ref_1; // Can copy the reference version.
drop((as_ref_1, as_ref_2));
sourcefn unref_ref(&self) -> <Self::UnRefVar as VariadicExt>::AsRefVar<'_>
fn unref_ref(&self) -> <Self::UnRefVar as VariadicExt>::AsRefVar<'_>
convert entries to <UnRefVar as VariadicExt>::AsRefVar
Object Safety§
This trait is not object safe.