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: 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 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> EncodeConvertArgument for Twhere T: Encode,

source§

impl<T> EncodeConvertReturn for Twhere T: EncodeReturn,

source§

impl<T> EncodeReturn for Twhere T: Encode,

source§

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

Available on crate feature unstable-encode-internals only.
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 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,