Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some doc links #606

Merged
merged 1 commit into from Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/fmt.rs
Expand Up @@ -63,103 +63,75 @@ impl fmt::UpperHex for Uuid {

/// Format a [`Uuid`] as a hyphenated string, like
/// `67e55044-10b1-426f-9247-bb680e5fe0c8`.
///
/// [`Uuid`]: ../struct.Uuid.html
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Hyphenated(Uuid);

/// Format a [`Uuid`] as a simple string, like
/// `67e5504410b1426f9247bb680e5fe0c8`.
///
/// [`Uuid`]: ../struct.Uuid.html
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Simple(Uuid);

/// Format a [`Uuid`] as a URN string, like
/// `urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8`.
///
/// [`Uuid`]: ../struct.Uuid.html
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Urn(Uuid);

/// Format a [`Uuid`] as a braced hyphenated string, like
/// `{67e55044-10b1-426f-9247-bb680e5fe0c8}`.
///
/// [`Uuid`]: ../struct.Uuid.html
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Braced(Uuid);

impl Uuid {
/// Get a [`Hyphenated`] formatter.
///
/// [`Hyphenated`]: adapter/struct.Hyphenated.html
#[inline]
pub const fn hyphenated(self) -> Hyphenated {
Hyphenated(self)
}

/// Get a borrowed [`Hyphenated`] formatter.
///
/// [`Hyphenated`]: adapter/struct.Hyphenated.html
#[inline]
pub fn as_hyphenated(&self) -> &Hyphenated {
// SAFETY: `Uuid` and `Hyphenated` have the same ABI
unsafe { &*(self as *const Uuid as *const Hyphenated) }
}

/// Get a [`Simple`] formatter.
///
/// [`Simple`]: adapter/struct.Simple.html
#[inline]
pub const fn simple(self) -> Simple {
Simple(self)
}

/// Get a borrowed [`Simple`] formatter.
///
/// [`Simple`]: adapter/struct.Simple.html
#[inline]
pub fn as_simple(&self) -> &Simple {
// SAFETY: `Uuid` and `Simple` have the same ABI
unsafe { &*(self as *const Uuid as *const Simple) }
}

/// Get a [`Urn`] formatter.
///
/// [`Uuid`]: ../struct.Uuid.html
/// [`Urn`]: adapter/struct.Urn.html
#[inline]
pub const fn urn(self) -> Urn {
Urn(self)
}

/// Get a borrowed [`Urn`] formatter.
///
/// [`Uuid`]: ../struct.Uuid.html
/// [`Urn`]: adapter/struct.Urn.html
#[inline]
pub fn as_urn(&self) -> &Urn {
// SAFETY: `Uuid` and `Urn` have the same ABI
unsafe { &*(self as *const Uuid as *const Urn) }
}

/// Get a [`Braced`] formatter.
///
/// [`Uuid`]: ../struct.Uuid.html
/// [`Braced`]: adapter/struct.Braced.html
#[inline]
pub const fn braced(self) -> Braced {
Braced(self)
}

/// Get a borrowed [`Braced`] formatter.
///
/// [`Uuid`]: ../struct.Uuid.html
/// [`Braced`]: adapter/struct.Braced.html
#[inline]
pub fn as_braced(&self) -> &Braced {
// SAFETY: `Uuid` and `Braced` have the same ABI
Expand Down