pub struct UnionField { /* private fields */ }Expand description
Implementations§
Source§impl UnionField
impl UnionField
Sourcepub unsafe fn new(
get_ptr: Option<for<'a, 'b> fn(&'a Value<'b>) -> Value<'a>>,
set_ptr: Option<fn(&mut Value<'_>, Value<'static>)>,
name: &'static str,
assoc_ty: Type,
field_ty: Type,
) -> UnionField
pub unsafe fn new( get_ptr: Option<for<'a, 'b> fn(&'a Value<'b>) -> Value<'a>>, set_ptr: Option<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
Sourcepub unsafe fn get_ref<'a>(
&self,
this: &'a Value<'a>,
) -> Result<Value<'a>, Error>
pub unsafe fn get_ref<'a>( &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.
Sourcepub unsafe fn set(
&self,
this: &mut Value<'_>,
other: Value<'static>,
) -> Result<(), Error>
pub unsafe fn set( &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.