[−][src]Struct rebound::UnionField
Info about a field on a union Type
. Separate from a normal Field
due to
the unsafety of accessing/setting union fields. Allows getting a reference to or setting the
content of this field on a Value
, assuming the reflection was configured to allow it.
Implementations
impl UnionField
[src]
pub unsafe fn new(
get_ptr: Option<Box<dyn Fn(&'a Value<'a>) -> Value<'a>>>,
set_ptr: Option<Box<dyn Fn(&mut Value<'_>, Value<'static>)>>,
name: &'static str,
assoc_ty: Type,
field_ty: Type
) -> UnionField
[src]
get_ptr: Option<Box<dyn Fn(&'a Value<'a>) -> Value<'a>>>,
set_ptr: Option<Box<dyn Fn(&mut Value<'_>, Value<'static>)>>,
name: &'static str,
assoc_ty: Type,
field_ty: Type
) -> UnionField
Internal Function, used to create a new union field
Safety
Should only be called within a ReflectedUnion
's fields
implementation
pub fn name(&self) -> &'static str
[src]
Get the name of this field
pub fn assoc_ty(&self) -> Type
[src]
Get the Type this field is defined on
pub fn ty(&self) -> Type
[src]
Get the Type of the data in this field
pub unsafe fn get_ref<'a>(
&self,
this: &'a Value<'a>
) -> Result<Value<'a>, Error>
[src]
&self,
this: &'a Value<'a>
) -> Result<Value<'a>, Error>
Get a reference to the data contained within this field on a Value
, assuming the Value
is of the correct type and the operation is supported.
Safety
This is unsafe for the same reason accessing a field on a union normally is, and assumes that the union content can be correctly interpreted as a value of this type.
pub unsafe fn set(
&self,
this: &mut Value<'_>,
other: Value<'static>
) -> Result<(), Error>
[src]
&self,
this: &mut Value<'_>,
other: Value<'static>
) -> Result<(), Error>
Set the data contained within this Field on a Value
, assuming the Values of both this
and other
are of the correct type and the operation is supported.
Safety
This is unsafe for the same reason setting a non-Copy field on a union normally is, reading the field may require the union content be read as a value of the type being set.
Auto Trait Implementations
impl !RefUnwindSafe for UnionField
[src]
impl !Send for UnionField
[src]
impl !Sync for UnionField
[src]
impl Unpin for UnionField
[src]
impl !UnwindSafe for UnionField
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,