Skip to main content

WtfString

Struct WtfString 

Source
pub struct WtfString<E: WtfEncoding> { /* private fields */ }
Expand description

An owned, growable string of code units in encoding E (the analog of OsString / String).

The backing buffer always carries a trailing E::NUL beyond the logical content, so content access (via Deref to WtfStr) excludes the terminator while a width-specific FFI surface can still reach it with no extra allocation – for the Wtf16 arm this is a terminated pointer for wide (*W) Win32 APIs (see Wtf16String::as_terminated_ptr). Content may itself contain interior NULs (parity with OsString); see WtfStr::has_interior_nul.

Implementations§

Source§

impl WtfString<Wtf16>

Source

pub fn from_os_str(s: &OsStr) -> Self

Encode an OsStr into owned WTF-16, converting once at the boundary.

Lossless: unpaired surrogates survive, so from_os_str(x).to_os_string() == x. This is the owning analog of collecting OsStrExt::encode_wide.

Source

pub fn from_wide(units: &[u16]) -> Self

Build from already-wide code units: the OsStringExt::from_wide analog.

Identical to from_units, named for drop-in familiarity when replacing an OsString::from_wide call site.

Source§

impl<E: WtfEncoding> WtfString<E>

Source

pub fn new() -> Self

Create an empty string (a buffer holding only the terminator).

Source

pub fn from_units(units: &[E::Unit]) -> Self

Create an owned string from content code units, appending the terminator.

Source

pub fn into_string(self) -> Result<String, Self>

Consume the string and decode it to a String if its content is well-formed for this encoding, otherwise return the original unchanged.

The native-u16 analog of OsString::into_string.

Source

pub fn push<S: AsRef<WtfStr<E>>>(&mut self, s: S)

Append s’s code units after the current content, re-establishing the terminator (the OsString::push analog).

There is deliberately no truncate/pop/indexed edit: like OsString, the content is opaque code units that may be ill-formed (D-4/D-15), so an arbitrary byte/unit-offset edit could split a multi-unit sequence into content with no way to detect the damage afterward (D-16).

Source

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

Encode s and append it, re-establishing the terminator: the str-ergonomic sibling of push, for callers without an existing WtfStr<E> to hand.

Source

pub fn clear(&mut self)

Truncate to empty, re-establishing the terminator (the OsString::clear analog).

Source

pub fn capacity(&self) -> usize

The number of content code units this string can hold without reallocating (excluding the always-reserved terminator slot); the OsString::capacity analog.

Source

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

Reserve capacity for at least additional more content code units without reallocating; the OsString::reserve analog.

Source

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

Reserve capacity for exactly additional more content code units (modulo allocator granularity); the OsString::reserve_exact analog.

Source

pub fn shrink_to_fit(&mut self)

Shrink the backing buffer’s capacity to fit its current content (plus the terminator); the OsString::shrink_to_fit analog.

Source

pub fn shrink_to(&mut self, min_capacity: usize)

Shrink the backing buffer’s capacity to hold at least min_capacity content code units (plus the terminator), never growing it; the OsString::shrink_to analog.

Source§

impl WtfString<Wtf16>

Source

pub fn as_terminated_ptr(&self) -> *const u16

A NUL-terminated *const u16 (LPCWSTR/PCWSTR) over the whole buffer.

The always-present terminator makes this allocation-free (D-7). It is a valid C string only when has_interior_nul is false; otherwise a reader stops at the first interior NUL. The pointer is valid while self is borrowed and unmodified.

Examples found in repository?
examples/win32_round_trip.rs (line 99)
92    fn full_path(input: &Wtf16String) -> Option<Wtf16String> {
93        // Pass 1: ask for the size. The terminator is already in the buffer, so
94        // handing over an `LPCWSTR` costs nothing.
95        // SAFETY: `as_terminated_ptr` is NUL-terminated and valid while
96        // `input` is borrowed; a zero length asks for the required size only.
97        let needed = unsafe {
98            GetFullPathNameW(
99                input.as_terminated_ptr(),
100                0,
101                core::ptr::null_mut(),
102                core::ptr::null_mut(),
103            )
104        };
105        if needed == 0 {
106            return None;
107        }
108
109        // `needed` counts the terminator; our capacity is a *content* length,
110        // and `with_capacity` reserves the terminator slot itself.
111        let mut out = Wtf16String::with_capacity(needed as usize - 1);
112
113        // Pass 2: let the API write straight into our buffer.
114        // SAFETY: the buffer has room for `needed` units (content + the
115        // reserved terminator slot), which is exactly what pass 1 asked for.
116        let written = unsafe {
117            GetFullPathNameW(
118                input.as_terminated_ptr(),
119                needed,
120                out.as_mut_ptr(),
121                core::ptr::null_mut(),
122            )
123        };
124        if written == 0 || written >= needed {
125            // Failed, or raced a directory change and now wants more room.
126            // `out`'s invariant is still broken here, so republish an empty
127            // string before dropping it (see `as_mut_ptr`'s contract).
128            // SAFETY: publishing zero content units is always in bounds.
129            unsafe { out.set_len_from_ffi(0) };
130            return None;
131        }
132
133        // `written` excludes the terminator, which is precisely the content
134        // length `set_len_from_ffi` wants -- no guessing about conventions.
135        // SAFETY: the API initialized `written` units and `written < needed`,
136        // so the appended terminator still fits.
137        unsafe { out.set_len_from_ffi(written as usize) };
138        Some(out)
139    }
Source

pub fn with_capacity(units: usize) -> Self

An empty string with room for units content code units to be filled in place via as_mut_ptr plus set_len_from_ffi.

The reserved capacity also covers the always-present terminator, so a later set_len_from_ffi of up to units content units re-establishes the invariant without reallocating (D-9).

Examples found in repository?
examples/win32_round_trip.rs (line 111)
92    fn full_path(input: &Wtf16String) -> Option<Wtf16String> {
93        // Pass 1: ask for the size. The terminator is already in the buffer, so
94        // handing over an `LPCWSTR` costs nothing.
95        // SAFETY: `as_terminated_ptr` is NUL-terminated and valid while
96        // `input` is borrowed; a zero length asks for the required size only.
97        let needed = unsafe {
98            GetFullPathNameW(
99                input.as_terminated_ptr(),
100                0,
101                core::ptr::null_mut(),
102                core::ptr::null_mut(),
103            )
104        };
105        if needed == 0 {
106            return None;
107        }
108
109        // `needed` counts the terminator; our capacity is a *content* length,
110        // and `with_capacity` reserves the terminator slot itself.
111        let mut out = Wtf16String::with_capacity(needed as usize - 1);
112
113        // Pass 2: let the API write straight into our buffer.
114        // SAFETY: the buffer has room for `needed` units (content + the
115        // reserved terminator slot), which is exactly what pass 1 asked for.
116        let written = unsafe {
117            GetFullPathNameW(
118                input.as_terminated_ptr(),
119                needed,
120                out.as_mut_ptr(),
121                core::ptr::null_mut(),
122            )
123        };
124        if written == 0 || written >= needed {
125            // Failed, or raced a directory change and now wants more room.
126            // `out`'s invariant is still broken here, so republish an empty
127            // string before dropping it (see `as_mut_ptr`'s contract).
128            // SAFETY: publishing zero content units is always in bounds.
129            unsafe { out.set_len_from_ffi(0) };
130            return None;
131        }
132
133        // `written` excludes the terminator, which is precisely the content
134        // length `set_len_from_ffi` wants -- no guessing about conventions.
135        // SAFETY: the API initialized `written` units and `written < needed`,
136        // so the appended terminator still fits.
137        unsafe { out.set_len_from_ffi(written as usize) };
138        Some(out)
139    }
Source

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

A mutable pointer to the start of the buffer, for a foreign buffer-fill.

with_capacity(n) reserves n + 1 units: room for n content units plus the terminator slot. A foreign API may fill up to n content units, and one more if it writes its own terminator into the reserved slot (n + 1 units total). Either way, pass only the content length to set_len_from_ffi, which publishes that length and re-establishes the terminator.

Writing through this pointer overwrites the buffer – including element 0, which is the sole terminator of a fresh with_capacity – so it breaks the always-terminated invariant until set_len_from_ffi restores it. Between the write and that call the value must not be observed through any other method (as_terminated_ptr, Deref content access, Clone, Debug, PartialEq, …): they could read a non-terminated or partially written buffer. This holds on failure paths too – if the foreign call fails, restore the invariant with set_len_from_ffi(0) (the empty string) or drop the value before any other use. The pointer is valid while self is borrowed and not reallocated.

Examples found in repository?
examples/win32_round_trip.rs (line 120)
92    fn full_path(input: &Wtf16String) -> Option<Wtf16String> {
93        // Pass 1: ask for the size. The terminator is already in the buffer, so
94        // handing over an `LPCWSTR` costs nothing.
95        // SAFETY: `as_terminated_ptr` is NUL-terminated and valid while
96        // `input` is borrowed; a zero length asks for the required size only.
97        let needed = unsafe {
98            GetFullPathNameW(
99                input.as_terminated_ptr(),
100                0,
101                core::ptr::null_mut(),
102                core::ptr::null_mut(),
103            )
104        };
105        if needed == 0 {
106            return None;
107        }
108
109        // `needed` counts the terminator; our capacity is a *content* length,
110        // and `with_capacity` reserves the terminator slot itself.
111        let mut out = Wtf16String::with_capacity(needed as usize - 1);
112
113        // Pass 2: let the API write straight into our buffer.
114        // SAFETY: the buffer has room for `needed` units (content + the
115        // reserved terminator slot), which is exactly what pass 1 asked for.
116        let written = unsafe {
117            GetFullPathNameW(
118                input.as_terminated_ptr(),
119                needed,
120                out.as_mut_ptr(),
121                core::ptr::null_mut(),
122            )
123        };
124        if written == 0 || written >= needed {
125            // Failed, or raced a directory change and now wants more room.
126            // `out`'s invariant is still broken here, so republish an empty
127            // string before dropping it (see `as_mut_ptr`'s contract).
128            // SAFETY: publishing zero content units is always in bounds.
129            unsafe { out.set_len_from_ffi(0) };
130            return None;
131        }
132
133        // `written` excludes the terminator, which is precisely the content
134        // length `set_len_from_ffi` wants -- no guessing about conventions.
135        // SAFETY: the API initialized `written` units and `written < needed`,
136        // so the appended terminator still fits.
137        unsafe { out.set_len_from_ffi(written as usize) };
138        Some(out)
139    }
Source

pub unsafe fn set_len_from_ffi(&mut self, content_units: usize)

Publish content_units content code units written into the buffer from as_mut_ptr, then append the terminator.

content_units counts content only and never includes a terminator. The written units are taken verbatim – they may themselves end in NUL, since interior NULs are permitted (see has_interior_nul) – and exactly one terminator is appended. A foreign API that reports a count including the terminator it wrote must subtract one and pass the content length; this method never inspects the buffer to guess the convention, so a genuine trailing content NUL is never mistaken for the terminator.

§Safety

The caller must guarantee that:

  • the first content_units code units at as_mut_ptr are initialized u16 values, and
  • content_units does not exceed the count requested via with_capacity, so the appended terminator fits without reallocating a buffer whose pointer the caller may still hold.
Examples found in repository?
examples/win32_round_trip.rs (line 129)
92    fn full_path(input: &Wtf16String) -> Option<Wtf16String> {
93        // Pass 1: ask for the size. The terminator is already in the buffer, so
94        // handing over an `LPCWSTR` costs nothing.
95        // SAFETY: `as_terminated_ptr` is NUL-terminated and valid while
96        // `input` is borrowed; a zero length asks for the required size only.
97        let needed = unsafe {
98            GetFullPathNameW(
99                input.as_terminated_ptr(),
100                0,
101                core::ptr::null_mut(),
102                core::ptr::null_mut(),
103            )
104        };
105        if needed == 0 {
106            return None;
107        }
108
109        // `needed` counts the terminator; our capacity is a *content* length,
110        // and `with_capacity` reserves the terminator slot itself.
111        let mut out = Wtf16String::with_capacity(needed as usize - 1);
112
113        // Pass 2: let the API write straight into our buffer.
114        // SAFETY: the buffer has room for `needed` units (content + the
115        // reserved terminator slot), which is exactly what pass 1 asked for.
116        let written = unsafe {
117            GetFullPathNameW(
118                input.as_terminated_ptr(),
119                needed,
120                out.as_mut_ptr(),
121                core::ptr::null_mut(),
122            )
123        };
124        if written == 0 || written >= needed {
125            // Failed, or raced a directory change and now wants more room.
126            // `out`'s invariant is still broken here, so republish an empty
127            // string before dropping it (see `as_mut_ptr`'s contract).
128            // SAFETY: publishing zero content units is always in bounds.
129            unsafe { out.set_len_from_ffi(0) };
130            return None;
131        }
132
133        // `written` excludes the terminator, which is precisely the content
134        // length `set_len_from_ffi` wants -- no guessing about conventions.
135        // SAFETY: the API initialized `written` units and `written < needed`,
136        // so the appended terminator still fits.
137        unsafe { out.set_len_from_ffi(written as usize) };
138        Some(out)
139    }
Source

pub unsafe fn from_wide_ptr(ptr: *const u16, len: usize) -> Self

Copy len content code units from a foreign *const u16 into a new owned string, appending the terminator.

For callee-allocated Win32 output: the bytes are copied, so the caller keeps ownership of (and remains responsible for freeing) the source buffer. The copy is lossless — arbitrary WTF-16, including unpaired surrogates, is preserved (D-4/D-9).

§Safety

This copies the range through core::slice::from_raw_parts and shares its preconditions. When len > 0 the caller must guarantee that:

  • ptr is non-null and properly aligned for u16;
  • ptr is valid for reads of len consecutive, initialized u16 values, all contained within a single allocated object;
  • the total size len * size_of::<u16>() is no larger than isize::MAX, and adding it to ptr does not wrap the address space; and
  • that region stays unmutated for the duration of the call.

When len == 0 the pointer is not dereferenced, so it may be null or dangling. No reference to ptr is retained past the call. len is a count of code units, not bytes, and excludes any terminator the callee may have written (pass the content length).

Methods from Deref<Target = WtfStr<E>>§

Source

pub fn as_units(&self) -> &[E::Unit]

The content code units (there is no terminator on a borrowed slice).

Source

pub fn len(&self) -> usize

The number of content code units (not bytes, not code points).

Examples found in repository?
examples/win32_round_trip.rs (line 86)
67    pub fn run() {
68        let input = Wtf16String::from(r"C:\Windows\System32\..\Temp");
69        println!("input : {input}");
70
71        match full_path(&input) {
72            Some(expanded) => println!("expanded: {expanded}"),
73            None => println!("expanded: <GetFullPathNameW failed>"),
74        }
75
76        compare(&Wtf16String::from("alpha"), &Wtf16String::from("beta"));
77        compare(&Wtf16String::from("beta"), &Wtf16String::from("alpha"));
78        compare(&Wtf16String::from("same"), &Wtf16String::from("same"));
79
80        // The counted pair works on a borrowed slice, which has no terminator
81        // of its own -- the length is what makes it well-defined.
82        let units: Vec<u16> = "borrowed".encode_utf16().collect();
83        let borrowed = Wtf16Str::from_units(&units);
84        println!(
85            "borrowed slice of {} units compares equal to itself: {}",
86            borrowed.len(),
87            ordinal(borrowed, borrowed) == CSTR_EQUAL
88        );
89    }
90
91    /// Terminated input, then buffer-fill output -- both without converting.
92    fn full_path(input: &Wtf16String) -> Option<Wtf16String> {
93        // Pass 1: ask for the size. The terminator is already in the buffer, so
94        // handing over an `LPCWSTR` costs nothing.
95        // SAFETY: `as_terminated_ptr` is NUL-terminated and valid while
96        // `input` is borrowed; a zero length asks for the required size only.
97        let needed = unsafe {
98            GetFullPathNameW(
99                input.as_terminated_ptr(),
100                0,
101                core::ptr::null_mut(),
102                core::ptr::null_mut(),
103            )
104        };
105        if needed == 0 {
106            return None;
107        }
108
109        // `needed` counts the terminator; our capacity is a *content* length,
110        // and `with_capacity` reserves the terminator slot itself.
111        let mut out = Wtf16String::with_capacity(needed as usize - 1);
112
113        // Pass 2: let the API write straight into our buffer.
114        // SAFETY: the buffer has room for `needed` units (content + the
115        // reserved terminator slot), which is exactly what pass 1 asked for.
116        let written = unsafe {
117            GetFullPathNameW(
118                input.as_terminated_ptr(),
119                needed,
120                out.as_mut_ptr(),
121                core::ptr::null_mut(),
122            )
123        };
124        if written == 0 || written >= needed {
125            // Failed, or raced a directory change and now wants more room.
126            // `out`'s invariant is still broken here, so republish an empty
127            // string before dropping it (see `as_mut_ptr`'s contract).
128            // SAFETY: publishing zero content units is always in bounds.
129            unsafe { out.set_len_from_ffi(0) };
130            return None;
131        }
132
133        // `written` excludes the terminator, which is precisely the content
134        // length `set_len_from_ffi` wants -- no guessing about conventions.
135        // SAFETY: the API initialized `written` units and `written < needed`,
136        // so the appended terminator still fits.
137        unsafe { out.set_len_from_ffi(written as usize) };
138        Some(out)
139    }
140
141    /// Counted input: pointer + length, no terminator required.
142    fn ordinal(a: &Wtf16Str, b: &Wtf16Str) -> i32 {
143        // SAFETY: each pointer is valid for exactly its own `len()` units while
144        // borrowed, which is the contract `CompareStringOrdinal` expects.
145        unsafe {
146            CompareStringOrdinal(
147                a.as_ptr(),
148                a.len() as i32,
149                b.as_ptr(),
150                b.len() as i32,
151                0, // case-sensitive
152            )
153        }
154    }
Source

pub fn is_empty(&self) -> bool

Whether the string has no content units.

Source

pub fn has_interior_nul(&self) -> bool

Whether the content contains a NUL (E::NUL) code unit.

For the Wtf16 arm, a terminated LPCWSTR view of an owned string is a valid C string only when this is false (see Wtf16String::as_terminated_ptr); counted access is always valid regardless of this encoding’s storage width.

Source

pub fn to_string_checked(&self) -> Option<String>

Decode to a String if the content is well-formed for this encoding.

Returns None for content a strict String cannot hold (e.g. an unpaired surrogate in WTF-16); use to_string_lossy to decode with replacement instead.

Source

pub fn to_string_lossy(&self) -> String

Decode to a String, replacing any ill-formed sequence with U+FFFD.

Trait Implementations§

Source§

impl<E: WtfEncoding> AsRef<WtfStr<E>> for WtfString<E>

Source§

fn as_ref(&self) -> &WtfStr<E>

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

impl<E: WtfEncoding> Borrow<WtfStr<E>> for WtfString<E>

Source§

fn borrow(&self) -> &WtfStr<E>

Immutably borrows from an owned value. Read more
Source§

impl<E: WtfEncoding> Clone for WtfString<E>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<E: WtfEncoding> Debug for WtfString<E>

Source§

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

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

impl<E: WtfEncoding> Default for WtfString<E>

Source§

fn default() -> Self

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

impl<E: WtfEncoding> Deref for WtfString<E>

Source§

type Target = WtfStr<E>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &WtfStr<E>

Dereferences the value.
Source§

impl<E: WtfEncoding> Display for WtfString<E>

Source§

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

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

impl<E: WtfEncoding> Eq for WtfString<E>

Source§

impl From<&WtfString<Wtf16>> for OsString

Source§

fn from(s: &Wtf16String) -> Self

Converts to this type from the input type.
Source§

impl<E: WtfEncoding> From<&str> for WtfString<E>

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl<E: WtfEncoding> From<String> for WtfString<E>

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<WtfString<Wtf16>> for OsString

Source§

fn from(s: Wtf16String) -> Self

Converts to this type from the input type.
Source§

impl<E: WtfEncoding> Hash for WtfString<E>

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<E: WtfEncoding> Ord for WtfString<E>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl<E: WtfEncoding> PartialEq for WtfString<E>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<E: WtfEncoding> PartialEq<&str> for WtfString<E>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<E: WtfEncoding> PartialEq<str> for WtfString<E>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<E: WtfEncoding> PartialOrd for WtfString<E>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

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

Auto Trait Implementations§

§

impl<E> Freeze for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: Freeze,

§

impl<E> RefUnwindSafe for WtfString<E>

§

impl<E> Send for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: Send,

§

impl<E> Sync for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: Sync,

§

impl<E> Unpin for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: Unpin,

§

impl<E> UnsafeUnpin for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: UnsafeUnpin,

§

impl<E> UnwindSafe for WtfString<E>
where Vec<<E as WtfEncoding>::Unit>: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.