@string
Dynamic heap allocated string.
struct String
ptr: *char,
line: usize,
len: usize
iterator_ptr: usize,
Methods:
fn new() String
Creates new empty string instance.
fn from(value: *char) String
Creates new string from CStr value (char pointer).
fn from_raw_parts(ptr: *void, len: usize, capacity: usize) String
Creates new string from provided pointer, length and capacity.
fn with_capacity(capacity: usize) String
Creates new empty string with provided capacity.
fn clone(&self) String
Clones string instance (allocates new heap string and copies value).
fn clone_reversed(&self) String
Clones string instance with reversed content.
fn len(&self) usize
Returns string's length.
fn capacity(&self) usize
Returns string's capacity.
fn push(&self, value: char)
Appends provided character to the end of string.
fn push_str(&self, value: *char)
Appends CStr value to the end of string.
fn push_string(&self, other: String)
Appends otherString
content to the end of current.
fn pop(&self) char
Removes last character and returns it. If empty returns '\0'
fn remove(&self, position: usize)
Removes character on specified position (capacity doesn't change).
truncate(&self, new_len: usize)
Truncates string's length (capacity doesn't change)
fn peek(&self, position: usize) char
Returns character on provided position. Panic if out of bounds.
fn set(&self, position: usize, value: char)
Replaces character on position with provided value. Panic if out of bounds.
fn contains(&self, value: char) bool
Returnstrue
if string instance contains provided char.
fn contains_str(&self, value: *char) bool
Returnstrue
if string instance contains provided CStr value.
fn replace(&self, from: *char, to: *char)
Replaces string occurences with provided CStr value.
find(&self, pattern: char) usize
Finds provided character in string and returns its index.
find_str(&self, pattern: *char) usize
Finds provided CStr occurence and returns index of its first character.
to_uppercase(&self) String
Returns clone of string instance in uppercase format.
to_lowercase(&self) String
Returns clone of string instance in lowercase format.
to_bytes(&self) Bytes
(fromstdlib.bytes
)
Returns string instance represented inBytes
structure.
clear(&self)
Clears string (capacity doesn't change).
reverse(&self)
Reverses string content.
is_empty(&self)
Returns if string content is empty.
fn as_ptr(&self) *char
Returns raw heap pointer.
Compiler Implementations:
fn display(&self) *char
fn drop(&self)
fn iterate(&self) (char, bool)
fn compare(&self, other: *String) i32
fn slice(&self, index: usize) char
fn slice_assign(&self, index: usize, value: char)
fn deref(&self) *char
For more information see Structures Implementations