Struct RefArg

Source
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§

Source§

impl<'r, T> RefArg<'r, T>

Source

pub fn new(shared_ref: &'r T) -> Self

Creates a new RefArg from a reference.

Unless you implement your own ToGodot impl, there is usually no reason to use this.

Source

pub fn get_ref(&self) -> &T

Returns the stored reference.

§Panics

If T is Option<Gd<...>>::None.

Source

pub fn get_ref_or_none(&self) -> Option<&T>

Returns the stored reference.

Returns None if T is Option<Gd<...>>::None.

Source

pub fn to_owned(&self) -> T
where T: Clone,

Returns the stored reference.

§Panics

If T is Option<Gd<...>>::None.

Trait Implementations§

Source§

impl<T> Debug for RefArg<'_, T>
where T: Debug,

Source§

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

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

impl<T> FromGodot for RefArg<'_, T>
where T: FromGodot,

Source§

fn try_from_godot(_via: Self::Via) -> Result<Self, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
Source§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
Source§

fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

Performs the conversion from a [Variant], returning Err on failure.
Source§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a [Variant]. Read more
Source§

impl<T> GodotConvert for RefArg<'_, T>
where T: GodotConvert,

Source§

type Via = <T as GodotConvert>::Via

The type through which Self is represented in Godot.
Source§

impl<T> GodotNullableFfi for RefArg<'_, T>

Source§

fn null() -> Self

Source§

fn is_null(&self) -> bool

Source§

fn flatten_option(opt: Option<Self>) -> Self

Source§

impl<T> ToGodot for RefArg<'_, T>
where T: ToGodot,

Source§

type ToVia<'v> = <T as ToGodot>::ToVia<'v> where Self: 'v

Target type of to_godot(), which can differ from Via for pass-by-reference types. Read more
Source§

fn to_godot(&self) -> Self::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
Source§

fn to_variant(&self) -> Variant

Converts this type to a [Variant].

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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.