FmtUtc2k

Struct FmtUtc2k 

Source
pub struct FmtUtc2k(/* private fields */);
Expand description

§Formatted UTC2K.

This is the formatted companion to Utc2k. You can use it to obtain a string version of the date, print it, etc.

While this acts essentially as a glorified String, it is sized exactly and therefore requires less memory to represent. It also implements Copy.

It follows the simple Unix date format of YYYY-MM-DD hh:mm:ss.

Speaking of, you can obtain an &str using AsRef<str>, Borrow<str>, or FmtUtc2k::as_str.

If you only want the date or time half, call FmtUtc2k::date or FmtUtc2k::time respectively.

§Examples

Generally it makes more sense to initialize a Utc2k first, but you can skip straight to a FmtUtc2k instead:

use utc2k::{FmtUtc2k, Utc2k};

// Start with the current date/time.
let date = FmtUtc2k::now();

// Source from a specific timestamp.
let date = FmtUtc2k::from(946_684_800_u32);
assert_eq!(date.as_str(), "2000-01-01 00:00:00");

// Source from a `Utc2k`.
let utc_date = Utc2k::from(946_684_800_u32);
assert_eq!(FmtUtc2k::from(utc_date), utc_date.formatted());

Implementations§

Source§

impl FmtUtc2k

§Min/Max.
Source

pub const MIN: Self

§Minimum Date/Time.
assert_eq!(
    utc2k::FmtUtc2k::MIN.as_str(),
    "2000-01-01 00:00:00",
);
Source

pub const MAX: Self

§Maximum Date/Time.
assert_eq!(
    utc2k::FmtUtc2k::MAX.as_str(),
    "2099-12-31 23:59:59",
);
Source

pub const LEN: usize = 19

§Length.

The length of the formatted datetime in string/byte form.

§Examples
use utc2k::FmtUtc2k;

assert_eq!(
    FmtUtc2k::MIN.as_str().len(),
    FmtUtc2k::LEN,
);
Source§

impl FmtUtc2k

§Instantiation/Reuse.
Source

pub const fn from_ascii(src: &[u8]) -> Option<Self>

§From ASCII Date/Time Slice.

Try to parse a date/time value from an ASCII slice, returning a FmtUtc2k instance if successful, None if not.

Note that this method will automatically clamp dates outside the supported 2000..=2099 range to FmtUtc2k::MIN/FmtUtc2k::MAX.

See Utc2k::from_ascii for a rundown of supported formats, etc.

§Examples
use utc2k::FmtUtc2k;

// Separators are flexible.
let dates: [&[u8]; 5] = [
    b"20250615",   // Squished.
    b"2025 06 15", // Spaced.
    b"2025/06/15", // Slashed.
    b"2025-06-15", // Dashed.
    b"2025#06#15", // Hashed? Haha.
];
for raw in dates {
    assert_eq!(
        FmtUtc2k::from_ascii(raw).unwrap().as_str(),
        "2025-06-15 00:00:00",
//                  ^  ^  ^ Time defaults to midnight.
    );
}

// Same for datetimes.
let datetimes: [&[u8]; 10] = [
    b"20250615123001",
    b"2025-06-15 12:30:01",
    b"2025-06-15T12:30:01Z",
    b"2025/06/15:12:30:01 GMT",
    b"2025/06/15:12:30:01 UT",
    b"2025/06/15:12:30:01 UTC",
    b"2025/06/15 12:30:01.000 +0000",
    b"2025/06/15 12:30:01+0000",
    b"2025/06/15T16:30:01+04:00",
    b"2025/06/15T05:30:01-07:00",
];
for raw in datetimes {
    assert_eq!(
        FmtUtc2k::from_ascii(raw).unwrap().as_str(),
        "2025-06-15 12:30:01",
    );
}
Source

pub const fn from_rfc2822(src: &[u8]) -> Option<Self>

§From RFC2822 Date/Time Slice.

Try to parse a date/time value from a RFC2822-formatted byte slice, returning a FmtUtc2k instance if successful, None if not.

§Examples
use utc2k::FmtUtc2k;

// This spec tolerates a lot of variation…
let dates: [&[u8]; 7] = [
    b"Tue, 1 Jul 2003 10:52:37 +0000",  // Single-digit day.
    b"Tue,  1 Jul 2003 10:52:37 +0000", // Digit/space substitution.
    b"Tue, 01 Jul 2003 10:52:37 +0000", // Leading zero.
    b"1 Jul 2003 10:52:37",             // No weekday or offset.
    b"01 Jul 2003 10:52:37",            // Same, but w/ leading zero.
    b"Tue, 01 Jul 2003 03:52:37 -0700", // Negative UTC offset.
    b"Tue, 1 Jul 2003 15:22:37 +0430",  // Positive UTC offset.
];

for raw in dates {
    assert_eq!(
        FmtUtc2k::from_rfc2822(raw).unwrap().as_str(),
        "2003-07-01 10:52:37",
    );
}

// The same variation exists for date-only representations too.
let dates: [&[u8]; 5] = [
    b"Tue, 1 Jul 2003",  // Single-digit day.
    b"Tue,  1 Jul 2003", // Digit/space substitution.
    b"Tue, 01 Jul 2003", // Leading zero.
    b"1 Jul 2003",       // No weekday or offset.
    b"01 Jul 2003",      // Same, but w/ leading zero.
];

for raw in dates {
    assert_eq!(
        FmtUtc2k::from_rfc2822(raw).unwrap().as_str(),
        "2003-07-01 00:00:00",
    );
}
Source

pub const fn from_unixtime(src: u32) -> Self

§From Timestamp.

Initialize a new FmtUtc2k from a unix timestamp, saturating to FmtUtc2k::MIN/FmtUtc2k::MAX if out of range.

§Examples
use utc2k::FmtUtc2k;

assert_eq!(
    FmtUtc2k::from_unixtime(1_748_672_925).as_str(),
    "2025-05-31 06:28:45",
);

// Same as the above, but using the `From<u32>` impl.
assert_eq!(
    FmtUtc2k::from(1_748_672_925_u32).as_str(),
    "2025-05-31 06:28:45",
);

// Out of range values will saturate to the boundaries of the
// century.
assert_eq!(
    FmtUtc2k::from_unixtime(0).as_str(),
    "2000-01-01 00:00:00",
);
assert_eq!(
    FmtUtc2k::from_unixtime(u32::MAX).as_str(),
    "2099-12-31 23:59:59",
);
Source

pub fn now() -> Self

§Now.

This returns an instance using the current unixtime as the seed.

Source

pub const fn set_datetime(&mut self, src: Utc2k)

§Set Date/Time.

This can be used to recycle an existing buffer.

As with all other part-based operations, overflows and underflows will be adjusted automatically, with minimum and maximum dates capped to FmtUtc2k::MIN and FmtUtc2k::MAX respectively.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let mut fmt = FmtUtc2k::default();
assert_eq!(fmt.as_str(), "2000-01-01 00:00:00");

fmt.set_datetime(Utc2k::MAX);
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");

fmt.set_datetime(Utc2k::MIN);
assert_eq!(fmt.as_str(), "2000-01-01 00:00:00");
Source

pub const fn set_parts(&mut self, y: u16, m: u8, d: u8, hh: u8, mm: u8, ss: u8)

§Set Parts.

This can be used to recycle an existing buffer.

As with all other part-based operations, overflows and underflows will be adjusted automatically, with minimum and maximum dates capped to FmtUtc2k::MIN and FmtUtc2k::MAX respectively.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let mut fmt = FmtUtc2k::default();
assert_eq!(fmt.as_str(), "2000-01-01 00:00:00");

fmt.set_parts(2010, 10, 31, 12, 33, 59);
assert_eq!(fmt.as_str(), "2010-10-31 12:33:59");

// And if you do something weird with the dates...
fmt.set_parts(2010, 10, 32, 12, 33, 59);
assert_eq!(fmt.as_str(), "2010-11-01 12:33:59");
Source

pub fn set_unixtime(&mut self, src: u32)

§Set Unixtime.

This can be used to recycle an existing buffer.

As with all other part-based operations, overflows and underflows will be adjusted automatically, with minimum and maximum dates capped to Utc2k::MIN_UNIXTIME and Utc2k::MAX_UNIXTIME respectively.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let mut fmt = FmtUtc2k::from(Utc2k::MIN_UNIXTIME);
assert_eq!(fmt.as_str(), "2000-01-01 00:00:00");

fmt.set_unixtime(Utc2k::MAX_UNIXTIME);
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
Source§

impl FmtUtc2k

§Getters.
Source

pub const fn as_bytes(&self) -> &[u8]

§As Bytes.

Return a byte string slice in YYYY-MM-DD hh:mm:ss format.

A byte slice can also be obtained using FmtUtc2k::as_ref.

§Examples
use utc2k::FmtUtc2k;

let fmt = FmtUtc2k::MAX;
assert_eq!(fmt.as_bytes(), b"2099-12-31 23:59:59");
Source

pub const fn as_str(&self) -> &str

§As Str.

Return a string slice in YYYY-MM-DD hh:mm:ss format.

§Examples
use utc2k::FmtUtc2k;

let fmt = FmtUtc2k::MAX;
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
Source

pub const fn date(&self) -> &str

§Just the Date Bits.

This returns the date as a string slice in YYYY-MM-DD format.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let fmt = FmtUtc2k::from(Utc2k::MAX_UNIXTIME);
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
assert_eq!(fmt.date(), "2099-12-31");
Source

pub const fn year(&self) -> &str

§Just the Year Bit.

This returns the year as a string slice.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let fmt = FmtUtc2k::from(Utc2k::MAX_UNIXTIME);
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
assert_eq!(fmt.year(), "2099");
Source

pub const fn time(&self) -> &str

§Just the Time Bits.

This returns the time as a string slice in hh:mm:ss format.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let fmt = FmtUtc2k::from(Utc2k::MAX_UNIXTIME);
assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
assert_eq!(fmt.time(), "23:59:59");
Source§

impl FmtUtc2k

§Formatting.
Source

pub fn to_rfc2822(&self) -> String

§To RFC2822.

Return a string formatted according to RFC2822.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let date = FmtUtc2k::from(Utc2k::new(2003, 7, 1, 10, 52, 37));
assert_eq!(
    date.to_rfc2822(),
    "Tue, 01 Jul 2003 10:52:37 +0000",
//        ^ This implementation zero-pads short day
//          numbers rather than truncating them…
);

let date = FmtUtc2k::from(Utc2k::new(2036, 12, 15, 16, 30, 55));
assert_eq!(
    date.to_rfc2822(),
    "Mon, 15 Dec 2036 16:30:55 +0000",
//   ^-----------------------------^ …to keep the output
//                                   length consistent.
);
Source

pub fn to_rfc3339(&self) -> String

§To RFC3339.

Return a string formatted according to RFC3339.

§Examples
use utc2k::{FmtUtc2k, Utc2k};

let mut fmt = FmtUtc2k::from(Utc2k::MIN_UNIXTIME);
assert_eq!(fmt.to_rfc3339(), "2000-01-01T00:00:00Z");

fmt.set_unixtime(Utc2k::MAX_UNIXTIME);
assert_eq!(fmt.to_rfc3339(), "2099-12-31T23:59:59Z");

// The reverse operation — parsing an RFC3339 datetime string into
// a FmtUtc2k — can be done using `FmtUtc2k::from_ascii`.
assert_eq!(
    FmtUtc2k::from_ascii(fmt.to_rfc3339().as_bytes()),
    Some(fmt),
);

Trait Implementations§

Source§

impl AsRef<[u8]> for FmtUtc2k

Source§

fn as_ref(&self) -> &[u8]

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

impl AsRef<str> for FmtUtc2k

Source§

fn as_ref(&self) -> &str

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

impl Borrow<str> for FmtUtc2k

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl Clone for FmtUtc2k

Source§

fn clone(&self) -> FmtUtc2k

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FmtUtc2k

Source§

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

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

impl Default for FmtUtc2k

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for FmtUtc2k

Available on crate feature serde only.
Source§

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

§Deserialize.

Use the optional serde crate feature to enable serialization support.

Source§

impl Display for FmtUtc2k

Source§

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

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

impl From<&FmtUtc2k> for Utc2k

Source§

fn from(src: &FmtUtc2k) -> Self

Converts to this type from the input type.
Source§

impl From<&Utc2k> for FmtUtc2k

Source§

fn from(src: &Utc2k) -> Self

Converts to this type from the input type.
Source§

impl From<FmtUtc2k> for String

Source§

fn from(src: FmtUtc2k) -> Self

§Into String.
use utc2k::FmtUtc2k;

assert_eq!(
    String::from(FmtUtc2k::from(1_750_620_170)),
    "2025-06-22 19:22:50",
);
Source§

impl From<FmtUtc2k> for Utc2k

Source§

fn from(src: FmtUtc2k) -> Self

§From FmtUtc2k.
use utc2k::{FmtUtc2k, Utc2k};

let fmt = FmtUtc2k::from(1_750_620_170);
let utc = Utc2k::from(fmt);
assert_eq!(
    utc.parts(),
    (2025, 6, 22, 19, 22, 50),
);
Source§

impl From<Utc2k> for FmtUtc2k

Source§

fn from(src: Utc2k) -> Self

§From Utc2k
use utc2k::{FmtUtc2k, Utc2k};

let utc = Utc2k::new(2025, 6, 22, 19, 22, 50);
assert_eq!(
    FmtUtc2k::from(utc),
    "2025-06-22 19:22:50",
);
Source§

impl From<u32> for FmtUtc2k

Source§

fn from(src: u32) -> Self

§From Unixtime.
use utc2k::FmtUtc2k;

assert_eq!(
    FmtUtc2k::from(1_750_620_170),
    "2025-06-22 19:22:50",
);
Source§

impl FromStr for FmtUtc2k

Source§

type Err = Utc2kError

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

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

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

impl Hash for FmtUtc2k

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 FmtUtc2k

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

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

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

impl PartialEq<&Box<str>> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Cow<'_, str>> for FmtUtc2k

Source§

fn eq(&self, other: &&Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&String> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Box<str>> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Cow<'_, str>> for FmtUtc2k

Source§

fn eq(&self, other: &Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for &Box<str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for &Cow<'_, str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for &String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for &str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for Box<str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for Cow<'_, str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<FmtUtc2k> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for FmtUtc2k

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FmtUtc2k

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 FmtUtc2k

Available on crate feature serde only.
Source§

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

§Serialize.

Use the optional serde crate feature to enable serialization support.

Source§

impl TryFrom<&[u8]> for FmtUtc2k

Source§

type Error = Utc2kError

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

fn try_from(src: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&OsStr> for FmtUtc2k

Source§

type Error = Utc2kError

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

fn try_from(src: &OsStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for FmtUtc2k

Source§

type Error = Utc2kError

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

fn try_from(src: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for FmtUtc2k

Source§

impl Eq for FmtUtc2k

Source§

impl StructuralPartialEq for FmtUtc2k

Auto Trait Implementations§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,