# 1.0.0[−][src]Struct std::ffi::CString

    pub struct CString { /* fields omitted */ }

A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the middle.

This type serves the purpose of being able to safely generate a C-compatible string from a Rust byte slice or vector. An instance of this type is a static guarantee that the underlying bytes contain no interior 0 bytes ("nul characters") and that the final byte is 0 ("nul terminator").

`CString` is to `&CStr` as `String` is to `&str`: the former in each pair are owned strings; the latter are borrowed references.

# Creating a `CString`

A `CString` is created from either a byte slice or a byte vector, or anything that implements `Into``<``Vec``<``u8``>>` (for example, you can build a `CString` straight out of a `String` or a `&str`, since both implement that trait).

The `CString::new` method will actually check that the provided `&[u8]` does not have 0 bytes in the middle, and return an error if it finds one.

# Extracting a raw pointer to the whole C string

`CString` implements a `as_ptr` method through the `Deref` trait. This method will give you a `*const c_char` which you can feed directly to extern functions that expect a nul-terminated string, like C's `strdup()`. Notice that `as_ptr` returns a read-only pointer; if the C code writes to it, that causes undefined behavior.

# Extracting a slice of the whole C string

Alternatively, you can obtain a `&[``u8``]` slice from a `CString` with the `CString::as_bytes` method. Slices produced in this way do not contain the trailing nul terminator. This is useful when you will be calling an extern function that takes a `*const u8` argument which is not necessarily nul-terminated, plus another argument with the length of the string — like C's `strndup()`. You can of course get the slice's length with its `len` method.

If you need a `&[``u8``]` slice with the nul terminator, you can use `CString::as_bytes_with_nul` instead.

Once you have the kind of slice you need (with or without a nul terminator), you can call the slice's own `as_ptr` method to get a read-only raw pointer to pass to extern functions. See the documentation for that function for a discussion on ensuring the lifetime of the raw pointer.

# Examples

ⓘThis example is not tested

    use std::ffi::CString;
    use std::os::raw::c_char;

    extern {
        fn my_printer(s: *const c_char);
    }

    // We are certain that our string doesn't have 0 bytes in the middle,
    // so we can .expect()
    let c_to_print = CString::new("Hello, world!").expect("CString::new failed");
    unsafe {
        my_printer(c_to_print.as_ptr());
    }

Run

# Safety

`CString` is intended for working with traditional C-style strings (a sequence of non-nul bytes terminated by a single nul byte); the primary use case for these kinds of strings is interoperating with C-like code. Often you will need to transfer ownership to/from that external code. It is strongly recommended that you thoroughly read through the documentation of `CString` before use, as improper ownership management of `CString` instances can lead to invalid memory accesses, memory leaks, and other memory errors.

## Implementations

### `impl CString`[src]

#### `pub fn new<T: Into<Vec<u8>>>(t: T) -> Result<CString, NulError>`[src]

Creates a new C-compatible string from a container of bytes.

This function will consume the provided data and use the underlying bytes to construct a new string, ensuring that there is a trailing 0 byte. This trailing 0 byte will be appended by this function; the provided data should not contain any 0 bytes in it.

# Examples

ⓘThis example is not tested

    use std::ffi::CString;
    use std::os::raw::c_char;

    extern { fn puts(s: *const c_char); }

    let to_print = CString::new("Hello!").expect("CString::new failed");
    unsafe {
        puts(to_print.as_ptr());
    }

Run

# Errors

This function will return an error if the supplied bytes contain an internal 0 byte. The `NulError` returned will contain the bytes as well as the position of the nul byte.

#### `pub unsafe fn from_vec_unchecked(v: Vec<u8>) -> CString`[src]

Creates a C-compatible string by consuming a byte vector, without checking for interior 0 bytes.

This method is equivalent to `CString::new` except that no runtime assertion is made that `v` contains no 0 bytes, and it requires an actual byte vector, not anything that can be converted to one with Into.

# Examples

    use std::ffi::CString;

    let raw = b"foo".to_vec();
    unsafe {
        let c_string = CString::from_vec_unchecked(raw);
    }

Run

#### `pub unsafe fn from_raw(ptr: *mut c_char) -> CString` 1.4.0[src]

Retakes ownership of a `CString` that was transferred to C via `CString::into_raw`.

Additionally, the length of the string will be recalculated from the pointer.

# Safety

This should only ever be called with a pointer that was earlier obtained by calling `CString::into_raw`. Other usage (e.g., trying to take ownership of a string that was allocated by foreign code) is likely to lead to undefined behavior or allocator corruption.

It should be noted that the length isn't just "recomputed," but that the recomputed length must match the original length from the `CString::into_raw` call. This means the `CString::into_raw`/`from_raw` methods should not be used when passing the string to C functions that can modify the string's length.

> Note: If you need to borrow a string that was allocated by foreign code, use `CStr`. If you need to take ownership of a string that was allocated by foreign code, you will need to make your own provisions for freeing it appropriately, likely with the foreign code's API to do that.

# Examples

Creates a `CString`, pass ownership to an `extern` function (via raw pointer), then retake ownership with `from_raw`:

ⓘThis example is not tested

    use std::ffi::CString;
    use std::os::raw::c_char;

    extern {
        fn some_extern_function(s: *mut c_char);
    }

    let c_string = CString::new("Hello!").expect("CString::new failed");
    let raw = c_string.into_raw();
    unsafe {
        some_extern_function(raw);
        let c_string = CString::from_raw(raw);
    }

Run

#### `pub fn into_raw(self) -> *mut c_char` 1.4.0[src]

Consumes the `CString` and transfers ownership of the string to a C caller.

The pointer which this function returns must be returned to Rust and reconstituted using `CString::from_raw` to be properly deallocated. Specifically, one should not use the standard C `free()` function to deallocate this string.

Failure to call `CString::from_raw` will lead to a memory leak.

The C side must not modify the length of the string (by writing a `NULL` somewhere inside the string or removing the final one) before it makes it back into Rust using `CString::from_raw`. See the safety section in `CString::from_raw`.

# Examples

    use std::ffi::CString;

    let c_string = CString::new("foo").expect("CString::new failed");

    let ptr = c_string.into_raw();

    unsafe {
        assert_eq!(b'f', *ptr as u8);
        assert_eq!(b'o', *ptr.offset(1) as u8);
        assert_eq!(b'o', *ptr.offset(2) as u8);
        assert_eq!(b'\0', *ptr.offset(3) as u8);

        // retake pointer to free memory
        let _ = CString::from_raw(ptr);
    }

Run

#### `pub fn into_string(self) -> Result<String, IntoStringError>`1.7.0[src]

Converts the `CString` into a `String` if it contains valid UTF-8 data.

On failure, ownership of the original `CString` is returned.

# Examples

    use std::ffi::CString;

    let valid_utf8 = vec![b'f', b'o', b'o'];
    let cstring = CString::new(valid_utf8).expect("CString::new failed");
    assert_eq!(cstring.into_string().expect("into_string() call failed"), "foo");

    let invalid_utf8 = vec![b'f', 0xff, b'o', b'o'];
    let cstring = CString::new(invalid_utf8).expect("CString::new failed");
    let err = cstring.into_string().err().expect("into_string().err() failed");
    assert_eq!(err.utf8_error().valid_up_to(), 1);

Run

#### `pub fn into_bytes(self) -> Vec<u8>ⓘ

### Notable traits for Vec<u8>

`impl Write for Vec<u8>`
`1.7.0[src]

Consumes the `CString` and returns the underlying byte buffer.

The returned buffer does not contain the trailing nul terminator, and it is guaranteed to not have any interior nul bytes.

# Examples

    use std::ffi::CString;

    let c_string = CString::new("foo").expect("CString::new failed");
    let bytes = c_string.into_bytes();
    assert_eq!(bytes, vec![b'f', b'o', b'o']);

Run

#### `pub fn into_bytes_with_nul(self) -> Vec<u8>ⓘ

### Notable traits for Vec<u8>

`impl Write for Vec<u8>`
`1.7.0[src]

Equivalent to `CString::into_bytes()` except that the returned vector includes the trailing nul terminator.

# Examples

    use std::ffi::CString;

    let c_string = CString::new("foo").expect("CString::new failed");
    let bytes = c_string.into_bytes_with_nul();
    assert_eq!(bytes, vec![b'f', b'o', b'o', b'\0']);

Run

#### `pub fn as_bytes(&self) -> &[u8]ⓘ

### Notable traits for &'_ [u8]

`impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]`
`[src]

Returns the contents of this `CString` as a slice of bytes.

The returned slice does not contain the trailing nul terminator, and it is guaranteed to not have any interior nul bytes. If you need the nul terminator, use `CString::as_bytes_with_nul` instead.

# Examples

    use std::ffi::CString;

    let c_string = CString::new("foo").expect("CString::new failed");
    let bytes = c_string.as_bytes();
    assert_eq!(bytes, &[b'f', b'o', b'o']);

Run

#### `pub fn as_bytes_with_nul(&self) -> &[u8]ⓘ

### Notable traits for &'_ [u8]

`impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]`
`[src]

Equivalent to `CString::as_bytes()` except that the returned slice includes the trailing nul terminator.

# Examples

    use std::ffi::CString;

    let c_string = CString::new("foo").expect("CString::new failed");
    let bytes = c_string.as_bytes_with_nul();
    assert_eq!(bytes, &[b'f', b'o', b'o', b'\0']);

Run

#### `pub fn as_c_str(&self) -> &CStr` 1.20.0[src]

Extracts a `CStr` slice containing the entire string.

# Examples

    use std::ffi::{CString, CStr};

    let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed");
    let cstr = c_string.as_c_str();
    assert_eq!(cstr,
               CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));

Run

#### `pub fn into_boxed_c_str(self) -> Box<CStr>ⓘ

### Notable traits for Box<F, A>

`impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for Box<R>impl<W: Write + ?Sized> Write for Box<W>`
`1.20.0[src]

Converts this `CString` into a boxed `CStr`.

# Examples

    use std::ffi::{CString, CStr};

    let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed");
    let boxed = c_string.into_boxed_c_str();
    assert_eq!(&*boxed,
               CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));

Run

#### `pub unsafe fn from_vec_with_nul_unchecked(v: Vec<u8>) -> Self`[src]

🔬 This is a nightly-only experimental API. (`cstring_from_vec_with_nul` #73179)

Converts a `Vec``<u8>` to a `CString` without checking the invariants on the given `Vec`.

# Safety

The given `Vec` must have one nul byte as its last element. This means it cannot be empty nor have any other nul byte anywhere else.

# Example

    #![feature(cstring_from_vec_with_nul)]
    use std::ffi::CString;
    assert_eq!(
        unsafe { CString::from_vec_with_nul_unchecked(b"abc\0".to_vec()) },
        unsafe { CString::from_vec_unchecked(b"abc".to_vec()) }
    );

Run

#### `pub fn from_vec_with_nul(v: Vec<u8>) -> Result<Self, FromVecWithNulError>`[src]

🔬 This is a nightly-only experimental API. (`cstring_from_vec_with_nul` #73179)

Attempts to converts a `Vec``<u8>` to a `CString`.

Runtime checks are present to ensure there is only one nul byte in the `Vec`, its last element.

# Errors

If a nul byte is present and not the last element or no nul bytes is present, an error will be returned.

# Examples

A successful conversion will produce the same result as `CString::new` when called without the ending nul byte.

    #![feature(cstring_from_vec_with_nul)]
    use std::ffi::CString;
    assert_eq!(
        CString::from_vec_with_nul(b"abc\0".to_vec())
            .expect("CString::from_vec_with_nul failed"),
        CString::new(b"abc".to_vec()).expect("CString::new failed")
    );

Run

A incorrectly formatted `Vec` will produce an error.

    #![feature(cstring_from_vec_with_nul)]
    use std::ffi::{CString, FromVecWithNulError};
    // Interior nul byte
    let _: FromVecWithNulError = CString::from_vec_with_nul(b"a\0bc".to_vec()).unwrap_err();
    // No nul byte
    let _: FromVecWithNulError = CString::from_vec_with_nul(b"abc".to_vec()).unwrap_err();

Run

## Methods from Deref<Target = CStr>

#### `pub const fn as_ptr(&self) -> *const c_char` 1.0.0 (const: 1.32.0)[src]

Returns the inner pointer to this C string.

The returned pointer will be valid for as long as `self` is, and points to a contiguous region of memory terminated with a 0 byte to represent the end of the string.

WARNING

The returned pointer is read-only; writing to it (including passing it to C code that writes to it) causes undefined behavior.

It is your responsibility to make sure that the underlying memory is not freed too early. For example, the following code will cause undefined behavior when `ptr` is used inside the `unsafe` block:

    use std::ffi::CString;

    let ptr = CString::new("Hello").expect("CString::new failed").as_ptr();
    unsafe {
        // `ptr` is dangling
        *ptr;
    }

Run

This happens because the pointer returned by `as_ptr` does not carry any lifetime information and the `CString` is deallocated immediately after the `CString::new("Hello").expect("CString::new failed").as_ptr()` expression is evaluated. To fix the problem, bind the `CString` to a local variable:

    use std::ffi::CString;

    let hello = CString::new("Hello").expect("CString::new failed");
    let ptr = hello.as_ptr();
    unsafe {
        // `ptr` is valid because `hello` is in scope
        *ptr;
    }

Run

This way, the lifetime of the `CString` in `hello` encompasses the lifetime of `ptr` and the `unsafe` block.

#### `pub fn to_bytes(&self) -> &[u8]ⓘ

### Notable traits for &'_ [u8]

`impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]`
`[src]

Converts this C string to a byte slice.

The returned slice will not contain the trailing nul terminator that this C string has.

> Note: This method is currently implemented as a constant-time cast, but it is planned to alter its definition in the future to perform the length calculation whenever this method is called.

# Examples

    use std::ffi::CStr;

    let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
    assert_eq!(cstr.to_bytes(), b"foo");

Run

#### `pub fn to_bytes_with_nul(&self) -> &[u8]ⓘ

### Notable traits for &'_ [u8]

`impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]`
`[src]

Converts this C string to a byte slice containing the trailing 0 byte.

This function is the equivalent of `CStr::to_bytes` except that it will retain the trailing nul terminator instead of chopping it off.

> Note: This method is currently implemented as a 0-cost cast, but it is planned to alter its definition in the future to perform the length calculation whenever this method is called.

# Examples

    use std::ffi::CStr;

    let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
    assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");

Run

#### `pub fn to_str(&self) -> Result<&str, Utf8Error>`1.4.0[src]

Yields a `&str` slice if the `CStr` contains valid UTF-8.

If the contents of the `CStr` are valid UTF-8 data, this function will return the corresponding `&str` slice. Otherwise, it will return an error with details of where UTF-8 validation failed.

# Examples

    use std::ffi::CStr;

    let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
    assert_eq!(cstr.to_str(), Ok("foo"));

Run

#### `pub fn to_string_lossy(&self) -> Cow<'_, str>`1.4.0[src]

Converts a `CStr` into a `Cow``<``str``>`.

If the contents of the `CStr` are valid UTF-8 data, this function will return a `Cow``::``Borrowed``(``&str``)` with the corresponding `&str` slice. Otherwise, it will replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT CHARACTER` and return a `Cow``::``Owned``(``String``)` with the result.

# Examples

Calling `to_string_lossy` on a `CStr` containing valid UTF-8:

    use std::borrow::Cow;
    use std::ffi::CStr;

    let cstr = CStr::from_bytes_with_nul(b"Hello World\0")
                     .expect("CStr::from_bytes_with_nul failed");
    assert_eq!(cstr.to_string_lossy(), Cow::Borrowed("Hello World"));

Run

Calling `to_string_lossy` on a `CStr` containing invalid UTF-8:

    use std::borrow::Cow;
    use std::ffi::CStr;

    let cstr = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
                     .expect("CStr::from_bytes_with_nul failed");
    assert_eq!(
        cstr.to_string_lossy(),
        Cow::Owned(String::from("Hello �World")) as Cow<'_, str>
    );

Run

## Trait Implementations

### `impl AsRef<CStr> for CString` 1.7.0[src]

#### `pub fn as_ref(&self) -> &CStr`[src]

Performs the conversion.

### `impl Borrow<CStr> for CString` 1.3.0[src]

#### `pub fn borrow(&self) -> &CStr`[src]

Immutably borrows from an owned value. Read more

### `impl Clone for CString`[src]

#### `pub fn clone(&self) -> CString`[src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`[src]

Performs copy-assignment from `source`. Read more

### `impl Debug for CString`[src]

#### `pub fn fmt(&self, f: &mut Formatter<'_>) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl Default for CString` 1.10.0[src]

#### `pub fn default() -> CString`[src]

Creates an empty `CString`.

### `impl Deref for CString`[src]

#### `type Target = CStr`

The resulting type after dereferencing.

#### `pub fn deref(&self) -> &CStr`[src]

Dereferences the value.

### `impl Drop for CString` 1.13.0[src]

#### `pub fn drop(&mut self)`[src]

Executes the destructor for this type. Read more

### `impl Eq for CString`[src]

### `impl<'_> From<&'_ CStr> for CString` 1.7.0[src]

#### `pub fn from(s: &CStr) -> CString`[src]

Performs the conversion.

### `impl<'a> From<&'a CString> for Cow<'a, CStr>`1.28.0[src]

#### `pub fn from(s: &'a CString) -> Cow<'a, CStr>`[src]

Performs the conversion.

### `impl From<Box<CStr, Global>> for CString` 1.18.0[src]

#### `pub fn from(s: Box<CStr>) -> CString`[src]

Converts a `Box``<CStr>` into a `CString` without copying or allocating.

### `impl From<CString> for Vec<u8>`1.7.0[src]

#### `pub fn from(s: CString) -> Vec<u8>ⓘ

### Notable traits for Vec<u8>

`impl Write for Vec<u8>`
`[src]

Converts a `CString` into a `Vec``<u8>`.

The conversion consumes the `CString`, and removes the terminating NUL byte.

### `impl From<CString> for Box<CStr>`1.20.0[src]

#### `pub fn from(s: CString) -> Box<CStr>ⓘ

### Notable traits for Box<F, A>

`impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for Box<R>impl<W: Write + ?Sized> Write for Box<W>`
`[src]

Converts a `CString` into a `Box``<CStr>` without copying or allocating.

### `impl<'a> From<CString> for Cow<'a, CStr>`1.28.0[src]

#### `pub fn from(s: CString) -> Cow<'a, CStr>`[src]

Performs the conversion.

### `impl From<CString> for Arc<CStr>`1.24.0[src]

#### `pub fn from(s: CString) -> Arc<CStr>`[src]

Converts a `CString` into a `Arc``<CStr>` without copying or allocating.

### `impl From<CString> for Rc<CStr>`1.24.0[src]

#### `pub fn from(s: CString) -> Rc<CStr>`[src]

Converts a `CString` into a `Rc``<CStr>` without copying or allocating.

### `impl<'a> From<Cow<'a, CStr>> for CString` 1.28.0[src]

#### `pub fn from(s: Cow<'a, CStr>) -> Self`[src]

Performs the conversion.

### `impl From<Vec<NonZeroU8, Global>> for CString` 1.43.0[src]

#### `pub fn from(v: Vec<NonZeroU8>) -> CString`[src]

Converts a `Vec``<``NonZeroU8``>` into a `CString` without copying nor checking for inner null bytes.

### `impl Hash for CString`[src]

#### `pub fn hash<__H: Hasher>(&self, state: &mut __H)`[src]

Feeds this value into the given `Hasher`. Read more

#### `pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,` 1.3.0[src]

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

### `impl Index<RangeFull> for CString` 1.7.0[src]

#### `type Output = CStr`

The returned type after indexing.

#### `pub fn index(&self, _index: RangeFull) -> &CStr`[src]

Performs the indexing (`container[index]`) operation.

### `impl Ord for CString`[src]

#### `pub fn cmp(&self, other: &CString) -> Ordering`[src]

This method returns an `Ordering` between `self` and `other`. Read more

#### `#[must_use]pub fn max(self, other: Self) -> Self` 1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `#[must_use]pub fn min(self, other: Self) -> Self` 1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self` 1.50.0[src]

Restrict a value to a certain interval. Read more

### `impl PartialEq<CString> for CString`[src]

#### `pub fn eq(&self, other: &CString) -> bool`[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `pub fn ne(&self, other: &CString) -> bool`[src]

This method tests for `!=`.

### `impl PartialOrd<CString> for CString`[src]

#### `pub fn partial_cmp(&self, other: &CString) -> Option<Ordering>`[src]

This method returns an ordering between `self` and `other` values if one exists. Read more

#### `pub fn lt(&self, other: &CString) -> bool`[src]

This method tests less than (for `self` and `other`) and is used by the `<` operator. Read more

#### `pub fn le(&self, other: &CString) -> bool`[src]

This method tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. Read more

#### `pub fn gt(&self, other: &CString) -> bool`[src]

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

#### `pub fn ge(&self, other: &CString) -> bool`[src]

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

### `impl StructuralEq for CString`[src]

### `impl StructuralPartialEq for CString`[src]

## Auto Trait Implementations

### `impl RefUnwindSafe for CString`

### `impl Send for CString`

### `impl Sync for CString`

### `impl Unpin for CString`

### `impl UnwindSafe for CString`

## Blanket Implementations

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

#### `pub fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

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

#### `pub fn borrow(&self) -> &Tⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized, '_> Read for &'_ mut Rimpl<W: Write + ?Sized, '_> Write for &'_ mut W`
`[src]

Immutably borrows from an owned value. Read more

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

#### `pub fn borrow_mut(&mut self) -> &mut Tⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized, '_> Read for &'_ mut Rimpl<W: Write + ?Sized, '_> Write for &'_ mut W`
`[src]

Mutably borrows from an owned value. Read more

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

#### `pub fn from(t: T) -> T`[src]

Performs the conversion.

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

#### `pub fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T`[src]

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

#### `pub fn clone_into(&self, target: &mut T)`[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into` #41263)

recently added

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

### `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.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `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.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.