Document sealed trait

This commit is contained in:
David Tolnay 2018-03-18 00:22:56 -07:00
parent f341315473
commit ef180dc6e7
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 5 additions and 0 deletions

View File

@ -23,12 +23,14 @@ use std::{fmt, io, mem, ptr, slice, str};
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use core::{fmt, mem, ptr, slice, str}; use core::{fmt, mem, ptr, slice, str};
/// Write integer to an `io::Write`.
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[inline] #[inline]
pub fn write<W: io::Write, V: Integer>(wr: W, value: V) -> io::Result<usize> { pub fn write<W: io::Write, V: Integer>(wr: W, value: V) -> io::Result<usize> {
value.write(wr) value.write(wr)
} }
/// Write integer to an `fmt::Write`.
#[inline] #[inline]
pub fn fmt<W: fmt::Write, V: Integer>(wr: W, value: V) -> fmt::Result { pub fn fmt<W: fmt::Write, V: Integer>(wr: W, value: V) -> fmt::Result {
value.fmt(wr) value.fmt(wr)
@ -39,6 +41,9 @@ mod private {
pub trait Sealed {} pub trait Sealed {}
} }
/// An integer that can be formatted by `itoa::write` and `itoa::fmt`.
///
/// This trait is sealed and cannot be implemented for types outside of itoa.
pub trait Integer: private::Sealed { pub trait Integer: private::Sealed {
// Not public API. // Not public API.
#[doc(hidden)] #[doc(hidden)]