[][src]Union high_mem_utils::CatchStr

pub union CatchStr<'a> {
    // some fields omitted
}
Deprecated since 0.2.5:

Catch has implementations for serve the same functionality

An union string that can be leaked or sealed(owned),useful when you want to give temporal global access to a particular string.

Methods

impl<'a> CatchStr<'a>[src]

pub fn new(a: String) -> Self[src]

Creates a new CatchStr with a leak, you can lately get the underlying string and consume the CatchStr with the seal method.

pub fn leaked(&self) -> &&'a mut str[src]

Returns a a reference to the leaked field,as the only safe ways for construct this union returns a leaked one,for warranty never transmute stack to heap data,this method does not use transmute implicitly.

pub fn seal(self) -> String[src]

Consumes the Catch and gets the inner String, preventing the memory leak.

This does a call to transmute but,as the only safe ways for construct this union return a leaked one,this never trigger undefined behavior by itself.

pub fn leak(self) -> &'a mut str[src]

Consumes the CatchStr and returns a mutable reference pointing to leaked data.

pub unsafe fn from_leaked(leaked: &'a mut str) -> Self[src]

Creates a new CatchStr from a &mut str,without checking if the referent is in the heap.

Safety

This function should only be used with data returned by the leak method from a safely constructed CatchStr or with data returned by Box::leak(string.into_boxed_str()) otherwise this will trigger undefined behavior if the seal method is called.

Auto Trait Implementations

impl<'a> RefUnwindSafe for CatchStr<'a>

impl<'a> Send for CatchStr<'a>

impl<'a> Sync for CatchStr<'a>

impl<'a> Unpin for CatchStr<'a>

impl<'a> !UnwindSafe for CatchStr<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.