Struct objc2_foundation::NSRange
source · [−]#[repr(C)]pub struct NSRange {
pub location: NSUInteger,
pub length: NSUInteger,
}
Expand description
TODO.
Fields
location: NSUInteger
The lower bound of the range (inclusive).
length: NSUInteger
The number of items in the range, starting from location
.
Implementations
sourceimpl NSRange
impl NSRange
sourcepub const fn new(location: usize, length: usize) -> Self
pub const fn new(location: usize, length: usize) -> Self
Create a new range with the given values.
Examples
use objc2_foundation::NSRange;
assert_eq!(NSRange::new(3, 2), NSRange::from(3..5));
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the range contains no items.
Examples
use objc2_foundation::NSRange;
assert!(!NSRange::from(3..5).is_empty());
assert!( NSRange::from(3..3).is_empty());
sourcepub fn contains(&self, index: usize) -> bool
pub fn contains(&self, index: usize) -> bool
Returns true
if the index is within the range.
Examples
use objc2_foundation::NSRange;
assert!(!NSRange::from(3..5).contains(2));
assert!( NSRange::from(3..5).contains(3));
assert!( NSRange::from(3..5).contains(4));
assert!(!NSRange::from(3..5).contains(5));
assert!(!NSRange::from(3..3).contains(3));
Trait Implementations
sourceimpl Ord for NSRange
impl Ord for NSRange
sourceimpl PartialOrd<NSRange> for NSRange
impl PartialOrd<NSRange> for NSRange
sourcefn partial_cmp(&self, other: &NSRange) -> Option<Ordering>
fn partial_cmp(&self, other: &NSRange) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl RefEncode for NSRange
impl RefEncode for NSRange
sourceconst ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING)
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING)
The Objective-C type-encoding for a reference of this type. Read more
impl Copy for NSRange
impl Eq for NSRange
impl StructuralEq for NSRange
impl StructuralPartialEq for NSRange
Auto Trait Implementations
impl RefUnwindSafe for NSRange
impl Send for NSRange
impl Sync for NSRange
impl Unpin for NSRange
impl UnwindSafe for NSRange
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more