Struct objc2::runtime::Bool

source ·
#[repr(transparent)]
pub struct Bool { /* private fields */ }
Expand description

The Objective-C BOOL type.

This is a thin wrapper-type over objc_sys::BOOL. It is intended that you convert this into a Rust bool with the Bool::as_bool method as soon as possible.

This is FFI-safe and can be used directly with msg_send! and extern functions.

Note that this is able to contain more states than bool on some platforms, but these cases should not be relied on!

Implementations§

source§

impl Bool

source

pub const YES: Bool = Self::from_raw(objc_sys::YES)

The equivalent of true for Objective-C’s BOOL type.

source

pub const NO: Bool = Self::from_raw(objc_sys::NO)

The equivalent of false for Objective-C’s BOOL type.

source

pub const fn new(value: bool) -> Bool

Creates an Objective-C boolean from a Rust boolean.

source

pub const fn from_raw(value: bool) -> Bool

Creates this from a boolean value received from a raw Objective-C API.

source

pub const fn as_raw(self) -> bool

Retrieves the inner objc_sys::BOOL boolean type, to be used in raw Objective-C APIs.

source

pub const fn is_false(self) -> bool

Returns true if self is NO.

You should prefer using as_bool.

source

pub const fn is_true(self) -> bool

Returns true if self is not NO.

You should prefer using as_bool.

source

pub const fn as_bool(self) -> bool

Converts this into the bool equivalent.

Trait Implementations§

source§

impl Clone for Bool

source§

fn clone(&self) -> Bool

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Bool

source§

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

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

impl Default for Bool

source§

fn default() -> Bool

Returns the “default value” for a type. Read more
source§

impl Encode for Bool

source§

const ENCODING: Encoding = objc_sys::BOOL::__ENCODING

The Objective-C type-encoding for this type.
source§

impl From<bool> for Bool

source§

fn from(b: bool) -> Bool

Converts to this type from the input type.
source§

impl RefEncode for Bool

source§

const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING)

The Objective-C type-encoding for a reference of this type. Read more
source§

impl Copy for Bool

Auto Trait Implementations§

§

impl RefUnwindSafe for Bool

§

impl Send for Bool

§

impl Sync for Bool

§

impl Unpin for Bool

§

impl UnwindSafe for Bool

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> EncodeConvert for Twhere T: Encode,

§

type __Inner = T

source§

const __ENCODING: Encoding = Self::ENCODING

source§

fn __from_inner(inner: <T as EncodeConvert>::__Inner) -> T

source§

fn __into_inner(self) -> <T as EncodeConvert>::__Inner

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> InnerIvarType for Twhere T: EncodeConvert,

source§

const __ENCODING: Encoding = const __ENCODING: Encoding = <Self as EncodeConvert>::__ENCODING;

§

type __Inner = T

§

type Output = T

The type that an Ivar containing this will dereference to. Read more
source§

const __MAY_DROP: bool = false

source§

unsafe fn __to_ref( inner: &<T as InnerIvarType>::__Inner ) -> &<T as InnerIvarType>::Output

source§

unsafe fn __to_mut( inner: &mut <T as InnerIvarType>::__Inner ) -> &mut <T as InnerIvarType>::Output

source§

fn __to_ptr( inner: NonNull<<T as InnerIvarType>::__Inner> ) -> NonNull<<T as InnerIvarType>::Output>

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<T> AutoreleaseSafe for Twhere T: ?Sized,