Skip to main content

Ulid

Struct Ulid 

Source
pub struct Ulid { /* private fields */ }
Expand description

The ULID data type.

Implementations§

Source§

impl Ulid

Source

pub fn generate() -> Self

Creates a new ULID.

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::generate();

assert_ne!(0, ulid.timestamp());

let ulid_string = ulid.to_string();
// every ulid has exactly 26 characters
assert_eq!(ulid_string.len(), 26);
§Panics

Panics if called after +10889-08-02T05:31:50.655Z.

Source

pub fn next_monotonic(previous_ulid: Self) -> Self

Creates the next monotonic ULID for the given previous_ulid.

If the random part of previous_ulid would overflow, this function returns a ULID with the random part set to zero.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_monotonic(previous_ulid);

assert_ne!(0, ulid.timestamp());
§Panics

Panics if called after +10889-08-02T05:31:50.655Z.

Source

pub fn next_strictly_monotonic(previous_ulid: Self) -> Option<Self>

Creates the next strictly monotonic ULID for the given previous_ulid.

If the random part of previous_ulid would overflow, this function returns None.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_strictly_monotonic(previous_ulid);

if let Some(ulid) = ulid {
    assert_ne!(0, ulid.timestamp());
}
§Panics

Panics if called after +10889-08-02T05:31:50.655Z.

Source

pub fn from_timestamp_with_rng<R>(timestamp: u64, rng: &mut R) -> Self
where R: Rng,

Creates a new ULID with the given timestamp obtaining randomness from rng.

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from_timestamp_with_rng(0, &mut rand::rng());

let timestamp = ulid.timestamp();

assert_eq!(timestamp, 0);
§Panics

Panics if timestamp is larger than 0xFFFF_FFFF_FFFF.

Source

pub fn next_monotonic_from_timestamp_with_rng<R>( previous_ulid: Self, timestamp: u64, rng: &mut R, ) -> Self
where R: Rng,

Creates the next monotonic ULID with the given previous_ulid, timestamp obtaining randomness from rng.

If the random part of previous_ulid would overflow, this function returns a ULID with the random part set to zero.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

assert_eq!(ulid, Ulid::from(1));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFE);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

assert_eq!(ulid, Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

// overflow results in zero random part
assert_eq!(ulid, Ulid::from(0));
§Panics

Panics if timestamp is larger than 0xFFFF_FFFF_FFFF.

Source

pub fn next_monotonic_from_timestamp_with_rng_and_postprocessor<R>( previous_ulid: Option<Self>, timestamp: u64, rng: &mut R, postprocessor: Option<&dyn Fn(Self) -> Self>, ) -> Self
where R: Rng,

Creates the next monotonic ULID with the given previous_ulid, timestamp obtaining randomness from rng. If a new ULID is created instead of simply incrementing the previous ULID, then postprocessor is used (if available) to transform the new ULID before returning it.

If the random part of previous_ulid would overflow, this function returns a ULID with the random part set to zero.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng_and_postprocessor(Some(previous_ulid), 0, &mut rand::rng(), None);

assert_eq!(ulid, Ulid::from(1));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFE);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng_and_postprocessor(Some(previous_ulid), 0, &mut rand::rng(), None);

assert_eq!(ulid, Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng_and_postprocessor(Some(previous_ulid), 0, &mut rand::rng(), None);

// overflow results in zero random part
assert_eq!(ulid, Ulid::from(0));
use rusty_ulid::Ulid;

fn postprocessor_fn(ulid: Ulid) -> Ulid {
    // zero out lowest 32 bits
    Ulid::from(u128::from(ulid) & 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_0000_0000)
}

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_monotonic_from_timestamp_with_rng_and_postprocessor(
    Some(previous_ulid),
    1,
    &mut rand::rng(),
    Some(&postprocessor_fn),
);

assert_eq!(0, u128::from(ulid) & 0xFFFF_FFFF);

let ulid = Ulid::next_monotonic_from_timestamp_with_rng_and_postprocessor(
    None,
    1,
    &mut rand::rng(),
    Some(&postprocessor_fn),
);

assert_eq!(0, u128::from(ulid) & 0xFFFF_FFFF);
assert_ne!(0, u128::from(ulid));
§Panics

Panics if timestamp is larger than 0xFFFF_FFFF_FFFF.

Source

pub fn next_strictly_monotonic_from_timestamp_with_rng<R>( previous_ulid: Self, timestamp: u64, rng: &mut R, ) -> Option<Self>
where R: Rng,

Creates the next strictly monotonic ULID with the given previous_ulid, timestamp obtaining randomness from rng.

If the random part of previous_ulid would overflow, this function returns None.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

assert_eq!(ulid, Some(Ulid::from(1)));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFE);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

assert_eq!(ulid, Some(Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF)));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng(previous_ulid, 0, &mut rand::rng());

// overflow results in None
assert_eq!(ulid, None);
§Panics

Panics if timestamp is larger than 0xFFFF_FFFF_FFFF.

Source

pub fn next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor<R>( previous_ulid: Option<Self>, timestamp: u64, rng: &mut R, postprocessor: Option<&dyn Fn(Self) -> Self>, ) -> Option<Self>
where R: Rng,

Creates the next strictly monotonic ULID with the given previous_ulid, timestamp obtaining randomness from rng.

If the random part of previous_ulid would overflow, this function returns None.

§Examples
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor(
    Some(previous_ulid),
    0,
    &mut rand::rng(),
    None,
);

assert_eq!(ulid, Some(Ulid::from(1)));
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFE);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor(
    Some(previous_ulid),
    0,
    &mut rand::rng(),
    None,
);

assert_eq!(
    ulid,
    Some(Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF))
);
use rusty_ulid::Ulid;

let previous_ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor(
    Some(previous_ulid),
    0,
    &mut rand::rng(),
    None,
);

// overflow results in None
assert_eq!(ulid, None);
use rusty_ulid::Ulid;

fn postprocessor_fn(ulid: Ulid) -> Ulid {
    // zero out lowest 32 bits
    Ulid::from(u128::from(ulid) & 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_0000_0000)
}

let previous_ulid = Ulid::from(0);
let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor(
    Some(previous_ulid),
    1,
    &mut rand::rng(),
    Some(&postprocessor_fn),
);
let ulid = ulid.unwrap();

assert_eq!(0, u128::from(ulid) & 0xFFFF_FFFF);

let ulid = Ulid::next_strictly_monotonic_from_timestamp_with_rng_and_postprocessor(
    None,
    1,
    &mut rand::rng(),
    Some(&postprocessor_fn),
);
let ulid = ulid.unwrap();

assert_eq!(0, u128::from(ulid) & 0xFFFF_FFFF);
assert_ne!(0, u128::from(ulid));
§Panics

Panics if timestamp is larger than 0xFFFF_FFFF_FFFF.

Source

pub fn timestamp(&self) -> u64

Returns the timestamp of this ULID as number of non-leap milliseconds since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).

§Examples
use rusty_ulid::Ulid;
use std::str::FromStr;

let ulid = Ulid::from_str("01CAH7NXGRDJNE9B1NY7PQGYV7")?;
let timestamp = ulid.timestamp();

assert_eq!(timestamp, 1523144390168);
Source

pub fn offsetdatetime(&self) -> OffsetDateTime

Returns the timestamp of this ULID as a OffsetDateTime.

§Examples
use rusty_ulid::Ulid;
use std::str::FromStr;

let ulid = Ulid::from_str("01CAH7NXGRDJNE9B1NY7PQGYV7")?;
let datetime = ulid.offsetdatetime();

assert_eq!(datetime.to_string(), "2018-04-07 23:39:50.168 +00:00:00");
Source

pub fn increment(self) -> Self

Returns a new ULID with the random part incremented by one.

Overflowing the random part resets it to zero without influencing the timestamp.

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from(0);
let incremented = ulid.increment();

assert_eq!(incremented, Ulid::from(1));
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFE);
let incremented = ulid.increment();

assert_eq!(incremented, Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF));
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x0000_0000_0000_FFFF_FFFF_FFFF_FFFF_FFFF);
let incremented = ulid.increment();

assert_eq!(incremented, Ulid::from(0));
Source

pub fn to_string(&self) -> String

Returns the string representaton of this ULID.

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from(0);

assert_eq!(ulid.to_string(), "00000000000000000000000000");
use rusty_ulid::Ulid;

let ulid = Ulid::from(0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF);

assert_eq!(ulid.to_string(), "7ZZZZZZZZZZZZZZZZZZZZZZZZZ");

Trait Implementations§

Source§

impl Clone for Ulid

Source§

fn clone(&self) -> Ulid

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 Copy for Ulid

Source§

impl Debug for Ulid

Source§

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

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

impl<'de> Deserialize<'de> for Ulid

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Ulid

Source§

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

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

impl Eq for Ulid

Source§

impl From<(u64, u64)> for Ulid

Source§

fn from(value: (u64, u64)) -> Self

§Examples
use rusty_ulid::Ulid;

let tuple = (0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F);

let ulid = Ulid::from(tuple);

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);
use rusty_ulid::Ulid;

let tuple = (0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F);

let ulid : Ulid = tuple.into();

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);
Source§

impl From<Ulid> for [u8; 16]

Source§

fn from(ulid: Ulid) -> Self

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

let bytes = <[u8; 16]>::from(ulid);

let expected_bytes: [u8; 16] = [
    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0, 0x0F,
];

assert_eq!(bytes, expected_bytes);
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

let bytes: [u8; 16] = ulid.into();

let expected_bytes: [u8; 16] = [
    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0, 0x0F,
];

assert_eq!(bytes, expected_bytes);
Source§

impl From<Ulid> for (u64, u64)

Source§

fn from(ulid: Ulid) -> Self

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

let tuple = <(u64, u64)>::from(ulid);

let expected_tuple = (0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F);

assert_eq!(tuple, expected_tuple);
use rusty_ulid::Ulid;

let ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

let tuple : (u64, u64) = ulid.into();

let expected_tuple = (0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F);

assert_eq!(tuple, expected_tuple);
Source§

impl From<Ulid> for u128

Source§

fn from(ulid: Ulid) -> Self

§Examples
use rusty_ulid::Ulid;

let ulid = Ulid::from((0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F));

let value = <u128>::from(ulid);

let expected_value = 0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F;

assert_eq!(value, expected_value);
use rusty_ulid::Ulid;

let ulid = Ulid::from((0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F));

let value : u128 = ulid.into();

let expected_value = 0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F;

assert_eq!(value, expected_value);
Source§

impl From<[u8; 16]> for Ulid

Source§

fn from(bytes: [u8; 16]) -> Self

§Examples
use rusty_ulid::Ulid;

let bytes: [u8; 16] = [
    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0, 0x0F,
];

let ulid = Ulid::from(bytes);

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);
use rusty_ulid::Ulid;

let bytes: [u8; 16] = [
    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0, 0x0F,
];

let ulid : Ulid = bytes.into();

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);
Source§

impl From<u128> for Ulid

Source§

fn from(value: u128) -> Self

§Examples
use rusty_ulid::Ulid;

let value = 0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F;

let ulid = Ulid::from(value);

let expected_ulid = Ulid::from((0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F));

assert_eq!(ulid, expected_ulid);
use rusty_ulid::Ulid;

let value = 0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F;

let ulid : Ulid = value.into();

let expected_ulid = Ulid::from((0x1122_3344_5566_7788, 0x99AA_BBCC_DDEE_F00F));

assert_eq!(ulid, expected_ulid);
Source§

impl FromStr for Ulid

Source§

type Err = DecodingError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Ulid

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 Ord for Ulid

Source§

fn cmp(&self, other: &Ulid) -> 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 PartialEq for Ulid

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Ulid

Source§

fn partial_cmp(&self, other: &Ulid) -> 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
Source§

impl Serialize for Ulid

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Ulid

Source§

impl TryFrom<&[u8]> for Ulid

Source§

fn try_from(bytes: &[u8]) -> Result<Self, DecodingError>

Returns a ULID for the given slice of bytes or DecodingError::InvalidLength if the slice does not contain exactly 16 bytes.

§Examples
use rusty_ulid::Ulid;
use std::convert::TryFrom;
use std::convert::TryInto;

let bytes: [u8; 18] = [
    0x00,
    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0, 0x0F,
    0x00,
];

let ulid : Ulid = Ulid::try_from(&bytes[1..17])?;

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);

let ulid : Ulid = (&bytes[1..17]).try_into()?;

let expected_ulid = Ulid::from(0x1122_3344_5566_7788_99AA_BBCC_DDEE_F00F);

assert_eq!(ulid, expected_ulid);
use rusty_ulid::Ulid;
use rusty_ulid::DecodingError;
use std::convert::TryFrom;

let mut bytes: [u8; 17] = [0; 17];
let result = Ulid::try_from(&bytes[0..]);

assert_eq!(result, Err(DecodingError::InvalidLength))
use rusty_ulid::Ulid;
use rusty_ulid::DecodingError;
use std::convert::TryFrom;

let mut bytes: [u8; 15] = [0; 15];
let result = Ulid::try_from(&bytes[0..]);

assert_eq!(result, Err(DecodingError::InvalidLength))
Source§

type Error = DecodingError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl Freeze for Ulid

§

impl RefUnwindSafe for Ulid

§

impl Send for Ulid

§

impl Sync for Ulid

§

impl Unpin for Ulid

§

impl UnsafeUnpin for Ulid

§

impl UnwindSafe for Ulid

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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