Struct objc2::runtime::Bool

source ·
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 as a substitute for BOOL in Objective-C. If your Objective-C code uses C99 _Bool, you should use a #[repr(transparent)] wrapper around bool instead.

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: Self = _

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

source

pub const NO: Self = _

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

source

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

Creates an Objective-C boolean from a Rust boolean.

source

pub const fn from_raw(value: BOOL) -> Self

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

source

pub const fn as_raw(self) -> BOOL

Retrieves the inner ffi::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

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 = ffi::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 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 = _

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

impl Copy for Bool

Auto Trait Implementations§

§

impl Freeze for Bool

§

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 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> EncodeArgument for T
where T: Encode,

source§

const ENCODING_ARGUMENT: Encoding = const ENCODING_ARGUMENT: Encoding = T::ENCODING;

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

impl<T> EncodeReturn for T
where T: Encode,

source§

const ENCODING_RETURN: Encoding = const ENCODING_RETURN: Encoding = T::ENCODING;

The Objective-C type-encoding for this type.
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> ToOwned for T
where 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 T
where 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 T
where 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 T
where T: ?Sized,