Struct RefArg
pub struct RefArg<'r, T> { /* private fields */ }
Expand description
Simple reference wrapper, used when passing arguments by-ref to Godot APIs.
This type is often used as the result of ToGodot::to_godot()
, if Self
is not a Copy
type.
Implementations§
§impl<'r, T> RefArg<'r, T>
impl<'r, T> RefArg<'r, T>
pub fn new(shared_ref: &'r T) -> RefArg<'r, T>
pub fn new(shared_ref: &'r T) -> RefArg<'r, T>
Creates a new RefArg
from a reference.
Unless you implement your own ToGodot
impl, there is usually no reason to use this.
pub fn get_ref_or_none(&self) -> Option<&T>where
T: GodotNullableFfi,
pub fn get_ref_or_none(&self) -> Option<&T>where
T: GodotNullableFfi,
Returns the stored reference.
Returns None
if T
is Option<Gd<...>>::None
.
Trait Implementations§
§impl<'r, T> FromGodot for RefArg<'r, T>where
T: FromGodot,
impl<'r, T> FromGodot for RefArg<'r, T>where
T: FromGodot,
§fn try_from_godot(
_via: <RefArg<'r, T> as GodotConvert>::Via,
) -> Result<RefArg<'r, T>, ConvertError>
fn try_from_godot( _via: <RefArg<'r, T> as GodotConvert>::Via, ) -> Result<RefArg<'r, T>, ConvertError>
Converts the Godot representation to this type, returning
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
⚠️ Converts the Godot representation to this type. Read more
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Performs the conversion from a
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl<'r, T> GodotConvert for RefArg<'r, T>where
T: GodotConvert,
impl<'r, T> GodotConvert for RefArg<'r, T>where
T: GodotConvert,
§type Via = <T as GodotConvert>::Via
type Via = <T as GodotConvert>::Via
The type through which
Self
is represented in Godot.§impl<'r, T> ToGodot for RefArg<'r, T>where
T: ToGodot,
impl<'r, T> ToGodot for RefArg<'r, T>where
T: ToGodot,
Auto Trait Implementations§
impl<'r, T> Freeze for RefArg<'r, T>
impl<'r, T> RefUnwindSafe for RefArg<'r, T>where
T: RefUnwindSafe,
impl<'r, T> Send for RefArg<'r, T>where
T: Sync,
impl<'r, T> Sync for RefArg<'r, T>where
T: Sync,
impl<'r, T> Unpin for RefArg<'r, T>
impl<'r, T> UnwindSafe for RefArg<'r, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more