Struct objc2::foundation::NSMutableString
source · [−]#[repr(C)]pub struct NSMutableString { /* private fields */ }
foundation
only.Expand description
A dynamic plain-text Unicode string object.
Implementations
sourceimpl NSMutableString
impl NSMutableString
Creating mutable strings.
sourcepub fn new() -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
pub fn new() -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
Construct an empty NSMutableString
.
sourcepub fn from_str(string: &str) -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
pub fn from_str(string: &str) -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
Creates a new NSMutableString
by copying the given string slice.
sourcepub fn from_nsstring(string: &NSString) -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
pub fn from_nsstring(string: &NSString) -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
Creates a new NSMutableString
from the given NSString
.
pub fn with_capacity(capacity: usize) -> Id<Self, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
sourceimpl NSMutableString
impl NSMutableString
Mutating strings.
Methods from Deref<Target = NSString>
sourcepub fn concat(&self, other: &Self) -> Id<Self, Shared>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
pub fn concat(&self, other: &Self) -> Id<Self, Shared>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
Create a new string by appending the given string to self.
Example
use objc2::ns_string;
let error_tag = ns_string!("Error: ");
let error_string = ns_string!("premature end of file.");
let error_message = error_tag.concat(error_string);
assert_eq!(&*error_message, ns_string!("Error: premature end of file."));
sourcepub fn join_path(&self, other: &Self) -> Id<Self, Shared>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
pub fn join_path(&self, other: &Self) -> Id<Self, Shared>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
Create a new string by appending the given string, separated by a path separator.
This is similar to Path::join
.
Note that this method only works with file paths (not, for example, string representations of URLs).
Examples
use objc2::ns_string;
let extension = ns_string!("scratch.tiff");
assert_eq!(&*ns_string!("/tmp").join_path(extension), ns_string!("/tmp/scratch.tiff"));
assert_eq!(&*ns_string!("/tmp/").join_path(extension), ns_string!("/tmp/scratch.tiff"));
assert_eq!(&*ns_string!("/").join_path(extension), ns_string!("/scratch.tiff"));
assert_eq!(&*ns_string!("").join_path(extension), ns_string!("scratch.tiff"));
sourcepub fn len_utf16(&self) -> usize
pub fn len_utf16(&self) -> usize
The number of UTF-16 code units in the string.
See also NSString::len
.
pub fn is_empty(&self) -> bool
sourcepub fn as_str<'r, 's: 'r, 'p: 'r>(&'s self, pool: &'p AutoreleasePool) -> &'r str
pub fn as_str<'r, 's: 'r, 'p: 'r>(&'s self, pool: &'p AutoreleasePool) -> &'r str
Get the str
representation of this.
TODO: Further explain this.
sourcepub fn has_prefix(&self, prefix: &NSString) -> bool
pub fn has_prefix(&self, prefix: &NSString) -> bool
Whether the given string matches the beginning characters of this string.
sourcepub fn has_suffix(&self, suffix: &NSString) -> bool
pub fn has_suffix(&self, suffix: &NSString) -> bool
Whether the given string matches the ending characters of this string.
Methods from Deref<Target = NSObject>
sourcepub fn is_kind_of<T: ClassType>(&self) -> bool
pub fn is_kind_of<T: ClassType>(&self) -> bool
Check if the object is an instance of the class, or one of it’s subclasses.
See Apple’s documentation for more details on what you may (and what you may not) do with this information.
Methods from Deref<Target = Object>
sourcepub unsafe fn ivar_ptr<T: Encode>(&self, name: &str) -> *mut T
pub unsafe fn ivar_ptr<T: Encode>(&self, name: &str) -> *mut T
Returns a pointer to the instance variable / ivar with the given name.
This is similar to UnsafeCell::get
, see that for more information
on what is and isn’t safe to do.
Usually you will have defined the instance variable yourself with
ClassBuilder::add_ivar
, the type of the ivar T
must match the
type used in that.
Attempting to access or modify private implementation details of a class that you do no control using this is not supported, and may invoke undefined behaviour.
Library implementors are strongly encouraged to expose a safe interface to the ivar.
Panics
May panic if the object has no ivar with the given name. May also
panic if the type encoding of the ivar differs from the type encoding
of T
.
This should purely seen as help while debugging and is not guaranteed
(e.g. it may be disabled when debug_assertions
are off).
Safety
The object must have an instance variable with the given name, and it
must be of type T
. Any invariants that the object have assumed about
the value of the instance variable must not be violated.
No thread syncronization is done on accesses to the variable, so you must ensure that any access to the returned pointer do not cause data races, and that Rust’s mutability rules are not otherwise violated.
sourcepub unsafe fn ivar<T: Encode>(&self, name: &str) -> &T
pub unsafe fn ivar<T: Encode>(&self, name: &str) -> &T
Returns a reference to the instance variable with the given name.
See Object::ivar_ptr
for more information, including on when this
panics.
Safety
The object must have an instance variable with the given name, and it
must be of type T
.
No thread syncronization is done, so you must ensure that no other
thread is concurrently mutating the variable. This requirement can be
considered upheld if all mutation happens through Object::ivar_mut
(since that takes &mut self
).
sourcepub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T
👎Deprecated: Use Object::ivar
instead.
pub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T
Use Object::ivar
instead.
sourcepub unsafe fn ivar_mut<T: Encode>(&mut self, name: &str) -> &mut T
pub unsafe fn ivar_mut<T: Encode>(&mut self, name: &str) -> &mut T
Returns a mutable reference to the ivar with the given name.
See Object::ivar_ptr
for more information, including on when this
panics.
Safety
The object must have an instance variable with the given name, and it
must be of type T
.
This access happens through &mut self
, which means we know it to be
the only reference, hence you do not need to do any work to ensure
that data races do not happen.
sourcepub unsafe fn get_mut_ivar<T: Encode>(&mut self, name: &str) -> &mut T
👎Deprecated: Use Object::ivar_mut
instead.
pub unsafe fn get_mut_ivar<T: Encode>(&mut self, name: &str) -> &mut T
Use Object::ivar_mut
instead.
sourcepub unsafe fn set_ivar<T: Encode>(&mut self, name: &str, value: T)
pub unsafe fn set_ivar<T: Encode>(&mut self, name: &str, value: T)
Sets the value of the ivar with the given name.
This is just a helpful shorthand for Object::ivar_mut
, see that
for more information.
Safety
Same as Object::ivar_mut
.
Trait Implementations
sourceimpl AddAssign<&NSString> for NSMutableString
impl AddAssign<&NSString> for NSMutableString
sourcefn add_assign(&mut self, other: &NSString)
fn add_assign(&mut self, other: &NSString)
Performs the +=
operation. Read more
sourceimpl AsMut<NSMutableString> for NSMutableString
impl AsMut<NSMutableString> for NSMutableString
sourceimpl AsMut<NSObject> for NSMutableString
impl AsMut<NSObject> for NSMutableString
sourceimpl AsMut<NSString> for NSMutableString
impl AsMut<NSString> for NSMutableString
sourceimpl AsMut<Object> for NSMutableString
impl AsMut<Object> for NSMutableString
sourceimpl AsRef<NSMutableString> for NSMutableString
impl AsRef<NSMutableString> for NSMutableString
sourceimpl AsRef<NSObject> for NSMutableString
impl AsRef<NSObject> for NSMutableString
sourceimpl AsRef<NSString> for NSMutableString
impl AsRef<NSString> for NSMutableString
sourceimpl AsRef<Object> for NSMutableString
impl AsRef<Object> for NSMutableString
sourceimpl Borrow<NSObject> for NSMutableString
impl Borrow<NSObject> for NSMutableString
sourceimpl Borrow<NSString> for NSMutableString
impl Borrow<NSString> for NSMutableString
sourceimpl Borrow<Object> for NSMutableString
impl Borrow<Object> for NSMutableString
sourceimpl BorrowMut<NSObject> for NSMutableString
impl BorrowMut<NSObject> for NSMutableString
sourcefn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
Mutably borrows from an owned value. Read more
sourceimpl BorrowMut<NSString> for NSMutableString
impl BorrowMut<NSString> for NSMutableString
sourcefn borrow_mut(&mut self) -> &mut NSString
fn borrow_mut(&mut self) -> &mut NSString
Mutably borrows from an owned value. Read more
sourceimpl BorrowMut<Object> for NSMutableString
impl BorrowMut<Object> for NSMutableString
sourcefn borrow_mut(&mut self) -> &mut Object
fn borrow_mut(&mut self) -> &mut Object
Mutably borrows from an owned value. Read more
sourceimpl ClassType for NSMutableString
impl ClassType for NSMutableString
sourceimpl Debug for NSMutableString
impl Debug for NSMutableString
sourceimpl DefaultId for NSMutableString
impl DefaultId for NSMutableString
sourcefn default_id() -> Id<Self, Self::Ownership>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
fn default_id() -> Id<Self, Self::Ownership>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
sourceimpl Deref for NSMutableString
impl Deref for NSMutableString
sourceimpl DerefMut for NSMutableString
impl DerefMut for NSMutableString
sourceimpl Display for NSMutableString
impl Display for NSMutableString
sourceimpl Hash for NSMutableString
impl Hash for NSMutableString
sourceimpl NSCopying for NSMutableString
impl NSCopying for NSMutableString
type Ownership = Shared
type Ownership = Shared
foundation
only.Indicates whether the type is mutable or immutable. Read more
sourcefn copy(&self) -> Id<Self::Output, Self::Ownership>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
fn copy(&self) -> Id<Self::Output, Self::Ownership>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
foundation
only.sourceimpl NSMutableCopying for NSMutableString
impl NSMutableCopying for NSMutableString
sourcefn mutable_copy(&self) -> Id<Self::Output, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
fn mutable_copy(&self) -> Id<Self::Output, Owned>ⓘNotable traits for Id<I, Owned>impl<I: Iterator + ?Sized> Iterator for Id<I, Owned> type Item = I::Item;impl<T: Read + ?Sized> Read for Id<T, Owned>impl<T: Write + ?Sized> Write for Id<T, Owned>impl<T: Future + Unpin + ?Sized> Future for Id<T, Owned> type Output = T::Output;
foundation
only.sourceimpl Ord for NSMutableString
impl Ord for NSMutableString
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<NSMutableString> for NSMutableString
impl PartialEq<NSMutableString> for NSMutableString
sourcefn eq(&self, other: &NSMutableString) -> bool
fn eq(&self, other: &NSMutableString) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<NSMutableString> for NSString
impl PartialEq<NSMutableString> for NSString
sourcefn eq(&self, other: &NSMutableString) -> bool
fn eq(&self, other: &NSMutableString) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<NSString> for NSMutableString
impl PartialEq<NSString> for NSMutableString
sourceimpl PartialOrd<NSMutableString> for NSMutableString
impl PartialOrd<NSMutableString> for NSMutableString
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> 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 PartialOrd<NSMutableString> for NSString
impl PartialOrd<NSMutableString> for NSString
sourcefn partial_cmp(&self, other: &NSMutableString) -> Option<Ordering>
fn partial_cmp(&self, other: &NSMutableString) -> 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 PartialOrd<NSString> for NSMutableString
impl PartialOrd<NSString> for NSMutableString
sourcefn partial_cmp(&self, other: &NSString) -> Option<Ordering>
fn partial_cmp(&self, other: &NSString) -> 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 NSMutableString
impl RefEncode for NSMutableString
sourceconst ENCODING_REF: Encoding = <NSString as crate::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSString as crate::RefEncode>::ENCODING_REF
The Objective-C type-encoding for a reference of this type. Read more
sourceimpl ToOwned for NSMutableString
impl ToOwned for NSMutableString
type Owned = Id<NSMutableString, Owned>
type Owned = Id<NSMutableString, Owned>
The resulting type after obtaining ownership.
sourcefn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl Write for NSMutableString
impl Write for NSMutableString
impl Eq for NSMutableString
impl Message for NSMutableString
impl StructuralEq for NSMutableString
impl StructuralPartialEq for NSMutableString
Auto Trait Implementations
impl RefUnwindSafe for NSMutableString
impl Send for NSMutableString
impl Sync for NSMutableString
impl !Unpin for NSMutableString
impl UnwindSafe for NSMutableString
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