Skip to main content

Array

Struct Array 

Source
pub struct Array<T: Obj>(/* private fields */);
Expand description

Objective-C NSArray wrapper.

Uses arc::R for retained objects and provides safe convenience helpers for common operations like iteration and bounds-checked access via get.

Implementations§

Source§

impl<T: Obj> Array<T>

NSPredicateSupport

Source

pub fn filtered_by_predicate_ar(&self, predicate: &Predicate) -> Rar<Self>

Source

pub fn filtered_by_predicate(&self, predicate: &Predicate) -> R<Self>

Source§

impl<T: Obj> Array<T>

Source

pub fn cls() -> &'static Class<Self>

Source

pub fn cls_ptr() -> *const c_void

Source

pub fn alloc() -> A<Self>

Source

pub fn new() -> R<Self>

Creates an empty array via alloc + init.

Source

pub fn empty() -> R<Self>

Source

pub fn _new() -> R<Self>

Alternate constructor using NS_ARRAY.new().

Prefer new(); this path is slower.

Source

pub fn from_slice(objs: &[&T]) -> R<Self>

Builds an array from borrowed object references.

Source

pub fn from_slice_retained(objs: &[R<T>]) -> R<Self>

Builds an array from retained objects.

Source

pub fn contains(&self, object: &T) -> bool

Returns true if object is present.

Source

pub fn len(&self) -> usize

Returns the number of elements.

Source

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

Returns the first element, or None if empty.

Source

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

Returns the last element, or None if empty.

Source

pub fn copy(&self) -> Retained<Self>

Returns an immutable retained copy.

Source

pub fn copy_mut(&self) -> Retained<ArrayMut<T>>

Returns a retained mutable copy.

Source

pub fn is_empty(&self) -> bool

Returns true if len() == 0.

Source

pub fn iter(&self) -> FeIterator<'_, Self, T>

Returns a fast enumeration iterator.

Source

pub unsafe fn get_throws_ar(&self, index: usize) -> Rar<T>

Returns the object at index.

§Safety

Throws an ObjC exception if index is out of bounds.

Source

pub unsafe fn get_throws(&self, index: usize) -> R<T>

Returns the object at index.

§Safety

Throws an ObjC exception if index is out of bounds.

Source

pub fn get<'ear>(&self, index: usize) -> ExResult<'ear, R<T>>

Returns the object at index, capturing ObjC exceptions as ExResult.

Source

pub fn as_cf(&self) -> &ArrayOf<T>

Source

pub fn as_cf_mut(&mut self) -> &mut ArrayOf<T>

Source§

impl<T: Obj> Array<T>

NSArrayDiffing

Source§

impl<T: Obj> Array<T>

Source

pub fn paths_matching_extensions_ar( &self, filter_types: &Array<String>, ) -> Rar<Array<String>>

Source

pub fn paths_matching_extensions( &self, filter_types: &Array<String>, ) -> R<Array<String>>

Methods from Deref<Target = Id>§

Source

pub unsafe fn value_for_key_throws_ar(&self, key: &String) -> Option<Rar<Self>>

Source

pub unsafe fn value_for_key_throws(&self, key: &String) -> Option<R<Self>>

Source

pub fn value_for_key<'ear>( &self, key: &String, ) -> ExResult<'ear, Option<R<Self>>>

Source

pub unsafe fn value_for_key_path_throws_ar( &self, key_path: &String, ) -> Option<Rar<Self>>

Source

pub unsafe fn value_for_key_path_throws( &self, key_path: &String, ) -> Option<R<Self>>

Source

pub fn value_for_key_path<'ear>( &self, key_path: &String, ) -> ExResult<'ear, Option<R<Self>>>

Source

pub fn as_type_ref(&self) -> &Type

Source

pub fn as_id_ref(&self) -> &Self

Source

pub fn is_equal(&self, other: &Self) -> bool

Source

pub fn hash(&self) -> UInteger

Source

pub fn as_ptr(&self) -> *const Self

Trait Implementations§

Source§

impl<T: Debug + Obj> Debug for Array<T>

Source§

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

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

impl<T: Obj> Deref for Array<T>

Source§

type Target = Id

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Obj> FastEnum<T> for Array<T>

Source§

fn count_by_enum( &self, state: &mut FeState<T>, objects: *mut *const T, count: usize, ) -> usize

Source§

fn iter(&self) -> FeIterator<'_, Self, T>

Source§

impl<T: Obj> Index<usize> for Array<T>

Available on crate feature cf only.
Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Obj> IndexMut<usize> for Array<T>

Available on crate feature cf only.
Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Obj for Array<T>
where T: Obj,

Source§

unsafe fn retain(id: &Self) -> R<Self>

Source§

unsafe fn release(id: &mut Self)

Source§

fn desc_ar(&self) -> Rar<String>

Source§

fn desc(&self) -> R<String>

Source§

fn debug_desc_ar(&self) -> Rar<String>

Source§

fn debug_desc(&self) -> R<String>

Source§

fn responds_to_sel(&self, sel: &Sel) -> bool

Source§

fn class(&self) -> &Class<Self>

Source§

fn is_kind_of_class<T: Obj>(&self, cls: &Class<T>) -> bool

Source§

fn try_cast<T: Obj>(&self, cls: &Class<T>) -> Option<&T>

Source§

fn try_cast_mut<T: Obj>(&mut self, cls: &Class<T>) -> Option<&mut T>

Source§

fn is_member_of_class<T: Obj>(&self, cls: &Class<T>) -> bool

Source§

fn is_tagged_ptr(&self) -> bool

Source§

fn as_id_ref(&self) -> &Id

Source§

impl<T> Send for Array<T>
where T: Send + Obj,

Auto Trait Implementations§

§

impl<T> !Sync for Array<T>

§

impl<T> Freeze for Array<T>

§

impl<T> RefUnwindSafe for Array<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Array<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Array<T>

§

impl<T> UnwindSafe for Array<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Release for T
where T: Obj,

Source§

unsafe fn release(&mut self)

Source§

impl<T> Retain for T
where T: Obj,

Source§

fn retained(&self) -> Retained<T>

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.