Struct objc2_foundation::NSRange
source · #[repr(C)]pub struct NSRange {
pub location: NSUInteger,
pub length: NSUInteger,
}
Available on crate feature
NSRange
only.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§
source§impl 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§
source§impl Ord for NSRange
impl Ord for NSRange
source§impl PartialEq for NSRange
impl PartialEq for NSRange
source§impl PartialOrd for NSRange
impl PartialOrd for NSRange
1.0.0 · source§fn 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 moresource§impl RefEncode for NSRange
impl RefEncode for NSRange
source§const ENCODING_REF: Encoding = _
const ENCODING_REF: Encoding = _
The Objective-C type-encoding for a reference of this type. Read more
impl Copy for NSRange
impl Eq for NSRange
impl StructuralPartialEq for NSRange
Auto Trait Implementations§
impl Freeze for NSRange
impl RefUnwindSafe for NSRange
impl Send for NSRange
impl Sync for NSRange
impl Unpin for NSRange
impl UnwindSafe for NSRange
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> EncodeArgument for Twhere
T: Encode,
impl<T> EncodeArgument for Twhere
T: Encode,
source§const ENCODING_ARGUMENT: Encoding = T::ENCODING
const ENCODING_ARGUMENT: Encoding = T::ENCODING
The Objective-C type-encoding for this type.
source§impl<T> EncodeReturn for Twhere
T: Encode,
impl<T> EncodeReturn for Twhere
T: Encode,
source§const ENCODING_RETURN: Encoding = T::ENCODING
const ENCODING_RETURN: Encoding = T::ENCODING
The Objective-C type-encoding for this type.