Skip to content

Commit

Permalink
Add documentation to associated types in libcore, libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov committed Feb 23, 2015
1 parent f0f7ca2 commit dab394c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libcore/iter.rs
Expand Up @@ -86,6 +86,7 @@ use usize;
#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling `.iter()` or a similar \
method"]
pub trait Iterator {
/// The type of the elements being iterated
#[stable(feature = "rust1", since = "1.0.0")]
type Item;

Expand Down Expand Up @@ -122,9 +123,11 @@ pub trait FromIterator<A> {
/// Conversion into an `Iterator`
#[stable(feature = "rust1", since = "1.0.0")]
pub trait IntoIterator {
/// The type of the elements being iterated
#[stable(feature = "rust1", since = "1.0.0")]
type Item;

/// A container for iterating over elements of type Item
#[stable(feature = "rust1", since = "1.0.0")]
type IntoIter: Iterator<Item=Self::Item>;

Expand Down
17 changes: 17 additions & 0 deletions src/libcore/ops.rs
Expand Up @@ -184,6 +184,7 @@ macro_rules! forward_ref_binop {
#[lang="add"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Add<RHS=Self> {
/// The resulting type after applying the `+` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -237,6 +238,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
#[lang="sub"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Sub<RHS=Self> {
/// The resulting type after applying the `-` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -290,6 +292,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
#[lang="mul"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Mul<RHS=Self> {
/// The resulting type after applying the `*` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -343,6 +346,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
#[lang="div"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Div<RHS=Self> {
/// The resulting type after applying the `/` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -396,6 +400,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
#[lang="rem"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Rem<RHS=Self> {
/// The resulting type after applying the `%` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output = Self;

Expand Down Expand Up @@ -468,6 +473,7 @@ rem_float_impl! { f64, fmod }
#[lang="neg"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Neg {
/// The resulting type after applying the `-` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -544,6 +550,7 @@ neg_uint_impl! { u64, i64 }
#[lang="not"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Not {
/// The resulting type after applying the `!` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -597,6 +604,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
#[lang="bitand"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait BitAnd<RHS=Self> {
/// The resulting type after applying the `&` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -650,6 +658,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
#[lang="bitor"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait BitOr<RHS=Self> {
/// The resulting type after applying the `|` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -703,6 +712,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
#[lang="bitxor"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait BitXor<RHS=Self> {
/// The resulting type after applying the `^` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -756,6 +766,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
#[lang="shl"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Shl<RHS> {
/// The resulting type after applying the `<<` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -827,6 +838,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
#[lang="shr"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Shr<RHS> {
/// The resulting type after applying the `>>` operator
#[stable(feature = "rust1", since = "1.0.0")]
type Output;

Expand Down Expand Up @@ -900,6 +912,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Index<Idx: ?Sized> {
/// The returned type after indexing
type Output: ?Sized;

/// The method for the indexing (`Foo[Bar]`) operation
Expand Down Expand Up @@ -1047,6 +1060,7 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeTo<Idx> {
#[lang="deref"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Deref {
/// The resulting type after dereferencing
#[stable(feature = "rust1", since = "1.0.0")]
type Target: ?Sized;

Expand Down Expand Up @@ -1122,6 +1136,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar]
pub trait Fn<Args> {
/// The returned type after the call operator is used.
type Output;

/// This is called when the call operator is used.
Expand All @@ -1133,6 +1148,7 @@ pub trait Fn<Args> {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar]
pub trait FnMut<Args> {
/// The returned type after the call operator is used.
type Output;

/// This is called when the call operator is used.
Expand All @@ -1144,6 +1160,7 @@ pub trait FnMut<Args> {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar]
pub trait FnOnce<Args> {
/// The returned type after the call operator is used.
type Output;

/// This is called when the call operator is used.
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/ptr.rs
Expand Up @@ -249,6 +249,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// Methods on raw pointers
#[stable(feature = "rust1", since = "1.0.0")]
pub trait PtrExt: Sized {
/// The type which is being pointed at
type Target;

/// Returns true if the pointer is null.
Expand Down Expand Up @@ -284,6 +285,7 @@ pub trait PtrExt: Sized {
/// Methods on mutable raw pointers
#[stable(feature = "rust1", since = "1.0.0")]
pub trait MutPtrExt {
/// The type which is being pointed at
type Target;

/// Returns `None` if the pointer is null, or else returns a mutable
Expand Down
1 change: 1 addition & 0 deletions src/libstd/ascii.rs
Expand Up @@ -37,6 +37,7 @@ pub trait OwnedAsciiExt {
/// Extension methods for ASCII-subset only operations on string slices
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsciiExt {
/// Container type for copied ASCII characters.
#[stable(feature = "rust1", since = "1.0.0")]
type Owned;

Expand Down
1 change: 1 addition & 0 deletions src/libstd/collections/hash/state.rs
Expand Up @@ -27,6 +27,7 @@ use marker;
/// to `Default` when asked to create a hasher.
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
pub trait HashState {
/// Type of the hasher that will be created.
type Hasher: hash::Hasher;

/// Creates a new hasher based on the given state of this object.
Expand Down

0 comments on commit dab394c

Please sign in to comment.