Struct imgui::ImString

source ·
pub struct ImString(_);
Expand description

A UTF-8 encoded, growable, implicitly nul-terminated string.

Implementations§

source§

impl ImString

source

pub fn new<T: Into<String>>(value: T) -> ImString

Creates a new ImString from an existing string.

source

pub fn with_capacity(capacity: usize) -> ImString

Creates a new empty ImString with a particular capacity

source

pub unsafe fn from_utf8_unchecked(v: Vec<u8>) -> ImString

Converts a vector of bytes to a ImString without checking that the string contains valid UTF-8

Safety

It is up to the caller to guarantee the vector contains valid UTF-8 and no null terminator.

source

pub unsafe fn from_utf8_with_nul_unchecked(v: Vec<u8>) -> ImString

Converts a vector of bytes to a ImString without checking that the string contains valid UTF-8

Safety

It is up to the caller to guarantee the vector contains valid UTF-8 and a null terminator.

source

pub fn clear(&mut self)

Truncates this ImString, removing all contents

source

pub fn push(&mut self, ch: char)

Appends the given character to the end of this ImString

source

pub fn push_str(&mut self, string: &str)

Appends a given string slice to the end of this ImString

source

pub fn capacity(&self) -> usize

Returns the capacity of this ImString in bytes

source

pub fn capacity_with_nul(&self) -> usize

Returns the capacity of this ImString in bytes, including the implicit null byte

source

pub fn reserve(&mut self, additional: usize)

Ensures that the capacity of this ImString is at least additional bytes larger than the current length.

The capacity may be increased by more than additional bytes.

source

pub fn reserve_exact(&mut self, additional: usize)

Ensures that the capacity of this ImString is at least additional bytes larger than the current length

source

pub fn as_ptr(&self) -> *const c_char

Returns a raw pointer to the underlying buffer

source

pub fn as_mut_ptr(&mut self) -> *mut c_char

Returns a raw mutable pointer to the underlying buffer.

If the underlying data is modified, refresh_len must be called afterwards.

source

pub unsafe fn refresh_len(&mut self)

Updates the underlying buffer length based on the current contents.

This function must be called if the underlying data is modified via a pointer obtained by as_mut_ptr.

Safety

It is up to the caller to guarantee the this ImString contains valid UTF-8 and a null terminator.

Methods from Deref<Target = ImStr>§

source

pub fn as_ptr(&self) -> *const c_char

Converts an imgui-rs string slice to a raw pointer

source

pub fn to_str(&self) -> &str

Converts an imgui-rs string slice to a normal string slice

source

pub fn is_empty(&self) -> bool

Returns true if the imgui-rs string slice is empty

Trait Implementations§

source§

impl AsRef<ImStr> for ImString

source§

fn as_ref(&self) -> &ImStr

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<str> for ImString

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<ImStr> for ImString

source§

fn borrow(&self) -> &ImStr

Immutably borrows from an owned value. Read more
source§

impl Borrow<str> for ImString

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl Clone for ImString

source§

fn clone(&self) -> ImString

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ImString

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ImString

source§

fn default() -> ImString

Returns the “default value” for a type. Read more
source§

impl Deref for ImString

§

type Target = ImStr

The resulting type after dereferencing.
source§

fn deref(&self) -> &ImStr

Dereferences the value.
source§

impl Display for ImString

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a ImString> for Cow<'a, ImStr>

source§

fn from(s: &'a ImString) -> Cow<'a, ImStr>

Converts to this type from the input type.
source§

impl<'a, T: ?Sized + AsRef<ImStr>> From<&'a T> for ImString

source§

fn from(s: &'a T) -> ImString

Converts to this type from the input type.
source§

impl<'a> From<ImString> for Cow<'a, ImStr>

source§

fn from(s: ImString) -> Cow<'a, ImStr>

Converts to this type from the input type.
source§

impl From<String> for ImString

source§

fn from(s: String) -> ImString

Converts to this type from the input type.
source§

impl Hash for ImString

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<RangeFull> for ImString

§

type Output = ImStr

The returned type after indexing.
source§

fn index(&self, _index: RangeFull) -> &ImStr

Performs the indexing (container[index]) operation. Read more
source§

impl Ord for ImString

source§

fn cmp(&self, other: &ImString) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<ImString> for ImString

source§

fn eq(&self, other: &ImString) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<ImString> for ImString

source§

fn partial_cmp(&self, other: &ImString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Write for ImString

source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

impl Eq for ImString

source§

impl StructuralEq for ImString

source§

impl StructuralPartialEq for ImString

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.