Trait AllocForStr

Source
pub trait AllocForStr {
    // Required methods
    fn galloc_owned_str(&self) -> BString<'static>;
    fn galloc_str(&self) -> &'static str;
}

Required Methods§

Source

fn galloc_owned_str(&self) -> BString<'static>

Source

fn galloc_str(&self) -> &'static str

Implementations on Foreign Types§

Source§

impl AllocForStr for str

Source§

fn galloc_owned_str(&self) -> BString<'static>

Provides a method to convert a str slice into a BString with a static lifetime.

It does so by calling the as_owned function on the string slice, which is likely intended to produce an owned version of the string that can be utilized where a borrowed string is not sufficient. This transformation is useful in scenarios where a persistent, non-borrowed string is required, for example, for storage in data structures that manage their own memory lifecycle.

Source§

fn galloc_str(&self) -> &'static str

Returns a reference to a static string by allocating storage for the given string slice.

This method takes a reference to a string slice (&self) and allocates it using the alloc_str function. The returned value is a reference to a static string, which implies that the allocated storage has a 'static lifetime and remains valid for the entire duration of the program. This function is useful when a longer-lived string reference is needed, potentially at the cost of additional memory allocation.

Implementors§