Struct fruity::foundation::NSRange
source · [−]#[repr(C)]pub struct NSRange {
pub location: NSUInteger,
pub length: NSUInteger,
}
Expand description
Describe a portion of a series, such as characters in a string or objects in an array.
Fields
location: NSUInteger
The start index (0 is the first, as in C arrays).
For type compatibility with the rest of the system, LONG_MAX
is the
maximum value you should use for location.
length: NSUInteger
The number of items in the range (can be 0).
For type compatibility with the rest of the system, LONG_MAX
is the
maximum value you should use for length.
Implementations
sourceimpl NSRange
impl NSRange
sourcepub const fn new(location: NSUInteger, length: NSUInteger) -> Self
pub const fn new(location: NSUInteger, length: NSUInteger) -> Self
Returns a range with the specified values.
This is equivalent to
NSMakeRange
.
sourcepub fn from_range(range: Range<NSUInteger>) -> Self
pub fn from_range(range: Range<NSUInteger>) -> Self
Converts from a native Rust range.
This takes into account empty ranges with an end
less than start
.
sourcepub fn from_nsstring(string: &NSString<'_>) -> Self
pub fn from_nsstring(string: &NSString<'_>) -> Self
Returns a range from a textual representation.
See documentation.
sourcepub fn contains(&self, location: NSUInteger) -> bool
pub fn contains(&self, location: NSUInteger) -> bool
Returns true
if location
is in self
.
This is equivalent to
NSLocationInRange
.
sourcepub fn end(&self) -> NSUInteger
pub fn end(&self) -> NSUInteger
Returns the sum of the location and length of the range.
The result wraps on overflow.
This is equivalent to
NSMaxRange
.
sourcepub fn to_nsstring(self) -> Arc<NSString<'static>>
pub fn to_nsstring(self) -> Arc<NSString<'static>>
Returns a string representation of self
.
See documentation.
sourcepub fn union(self, other: Self) -> Self
pub fn union(self, other: Self) -> Self
Returns a range covering all indices in and between self
and other
.
See documentation.
sourcepub fn intersection(self, other: Self) -> Self
pub fn intersection(self, other: Self) -> Self
Returns a range covering all indices in and between self
and other
.
If the returned range’s length
is 0, then the two ranges don’t
intersect, and the value of location
is undefined.
See documentation.
Trait Implementations
sourceimpl From<Range<usize>> for NSRange
impl From<Range<usize>> for NSRange
sourcefn from(range: Range<NSUInteger>) -> Self
fn from(range: Range<NSUInteger>) -> Self
Converts to this type from the input type.
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
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more