Skip to content

Clean up std primitive docs #27168

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

Merged
merged 3 commits into from
Jul 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Utilities for slice manipulation
//! A dynamically-sized view into a contiguous sequence, `[T]`.
//!
//! The `slice` module contains useful code to help work with slice values.
//! Slices are a view into a block of memory represented as a pointer and a
//! length.
//!
Expand Down Expand Up @@ -78,7 +77,8 @@
//! iterators.
//! * Further methods that return iterators are `.split()`, `.splitn()`,
//! `.chunks()`, `.windows()` and more.
#![doc(primitive = "slice")]
//!
//! *[See also the slice primitive type](../primitive.slice.html).*
#![stable(feature = "rust1", since = "1.0.0")]

// Many of the usings in this module are only used in the test configuration.
Expand Down
38 changes: 3 additions & 35 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Unicode string manipulation (the `str` type).
//! Unicode string slices
//!
//! Rust's `str` type is one of the core primitive types of the language. `&str`
//! is the borrowed string type. This type of string can only be created from
//! other strings, unless it is a `&'static str` (see below). It is not possible
//! to move out of borrowed strings because they are owned elsewhere.
//!
//! # Examples
//!
//! Here's some code that uses a `&str`:
//!
//! ```
//! let s = "Hello, world.";
//! ```
//!
//! This `&str` is a `&'static str`, which is the type of string literals.
//! They're `'static` because literals are available for the entire lifetime of
//! the program.
//!
//! You can get a non-`'static` `&str` by taking a slice of a `String`:
//!
//! ```
//! let some_string = "Hello, world.".to_string();
//! let s = &some_string;
//! ```
//!
//! # Representation
//!
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as
//! a stream of UTF-8 bytes. All [strings](../../reference.html#literals) are
//! guaranteed to be validly encoded UTF-8 sequences. Additionally, strings are
//! not null-terminated and can thus contain null bytes.
//!
//! The actual representation of `str`s have direct mappings to slices: `&str`
//! is the same as `&[u8]`.
//! *[See also the `str` primitive type](../primitive.str.html).*


#![doc(primitive = "str")]
#![stable(feature = "rust1", since = "1.0.0")]

// Many of the usings in this module are only used in the test configuration.
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
//! Implementations of things like `Eq` for fixed-length arrays
//! up to a certain length. Eventually we should able to generalize
//! to all lengths.
//!
//! *[See also the array primitive type](../primitive.array.html).*

#![doc(primitive = "array")]
#![unstable(feature = "fixed_size_array",
reason = "traits and impls are better expressed through generic \
integer constants")]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! For more details, see ::rustc_unicode::char (a.k.a. std::char)

#![allow(non_snake_case)]
#![doc(primitive = "char")]
#![stable(feature = "core_char", since = "1.2.0")]

use iter::Iterator;
Expand Down
4 changes: 0 additions & 4 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ pub mod str;
pub mod hash;
pub mod fmt;

#[doc(primitive = "bool")]
mod bool {
}

// note: does not need to be public
mod tuple;

Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! Operations and constants for 32-bits floats (`f32` type)

#![doc(primitive = "f32")]
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(overflowing_literals)]

Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! Operations and constants for 64-bits floats (`f64` type)

#![doc(primitive = "f64")]
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(overflowing_literals)]

Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for signed 16-bits integers (`i16` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "i16")]

int_module! { i16, 16 }
1 change: 0 additions & 1 deletion src/libcore/num/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for signed 32-bits integers (`i32` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "i32")]

int_module! { i32, 32 }
1 change: 0 additions & 1 deletion src/libcore/num/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for signed 64-bits integers (`i64` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "i64")]

int_module! { i64, 64 }
1 change: 0 additions & 1 deletion src/libcore/num/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for signed 8-bits integers (`i8` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "i8")]

int_module! { i8, 8 }
1 change: 0 additions & 1 deletion src/libcore/num/isize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! Operations and constants for pointer-sized signed integers (`isize` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "isize")]

#[cfg(target_pointer_width = "32")]
int_module! { isize, 32 }
Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for unsigned 16-bits integers (`u16` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "u16")]

uint_module! { u16, i16, 16 }
1 change: 0 additions & 1 deletion src/libcore/num/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for unsigned 32-bits integers (`u32` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "u32")]

uint_module! { u32, i32, 32 }
1 change: 0 additions & 1 deletion src/libcore/num/u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for unsigned 64-bits integer (`u64` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "u64")]

uint_module! { u64, i64, 64 }
1 change: 0 additions & 1 deletion src/libcore/num/u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for unsigned 8-bits integers (`u8` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "u8")]

uint_module! { u8, i8, 8 }
1 change: 0 additions & 1 deletion src/libcore/num/usize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! Operations and constants for pointer-sized unsigned integers (`usize` type)

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "usize")]

uint_module! { usize, isize, ::isize::BITS }
77 changes: 2 additions & 75 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,84 +10,11 @@

// FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory

//! Operations on raw pointers, `*const T`, and `*mut T`.
//! Raw, unsafe pointers, `*const T`, and `*mut T`
//!
//! Working with raw pointers in Rust is uncommon,
//! typically limited to a few patterns.
//!
//! Use the `null` function to create null pointers, and the `is_null` method
//! of the `*const T` type to check for null. The `*const T` type also defines
//! the `offset` method, for pointer math.
//!
//! # Common ways to create raw pointers
//!
//! ## 1. Coerce a reference (`&T`) or mutable reference (`&mut T`).
//!
//! ```
//! let my_num: i32 = 10;
//! let my_num_ptr: *const i32 = &my_num;
//! let mut my_speed: i32 = 88;
//! let my_speed_ptr: *mut i32 = &mut my_speed;
//! ```
//!
//! To get a pointer to a boxed value, dereference the box:
//!
//! ```
//! let my_num: Box<i32> = Box::new(10);
//! let my_num_ptr: *const i32 = &*my_num;
//! let mut my_speed: Box<i32> = Box::new(88);
//! let my_speed_ptr: *mut i32 = &mut *my_speed;
//! ```
//!
//! This does not take ownership of the original allocation
//! and requires no resource management later,
//! but you must not use the pointer after its lifetime.
//!
//! ## 2. Consume a box (`Box<T>`).
//!
//! The `into_raw` function consumes a box and returns
//! the raw pointer. It doesn't destroy `T` or deallocate any memory.
//!
//! ```
//! # #![feature(box_raw)]
//! let my_speed: Box<i32> = Box::new(88);
//! let my_speed: *mut i32 = Box::into_raw(my_speed);
//!
//! // By taking ownership of the original `Box<T>` though
//! // we are obligated to put it together later to be destroyed.
//! unsafe {
//! drop(Box::from_raw(my_speed));
//! }
//! ```
//!
//! Note that here the call to `drop` is for clarity - it indicates
//! that we are done with the given value and it should be destroyed.
//!
//! ## 3. Get it from C.
//!
//! ```
//! # #![feature(libc)]
//! extern crate libc;
//!
//! use std::mem;
//!
//! fn main() {
//! unsafe {
//! let my_num: *mut i32 = libc::malloc(mem::size_of::<i32>() as libc::size_t) as *mut i32;
//! if my_num.is_null() {
//! panic!("failed to allocate memory");
//! }
//! libc::free(my_num as *mut libc::c_void);
//! }
//! }
//! ```
//!
//! Usually you wouldn't literally use `malloc` and `free` from Rust,
//! but C APIs hand out a lot of pointers generally, so are a common source
//! of raw pointers in Rust.
//! *[See also the pointer primitive types](../primitive.pointer.html).*

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "pointer")]

use mem;
use clone::Clone;
Expand Down
1 change: 0 additions & 1 deletion src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! For more details `std::slice`.

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "slice")]

// How this module is organized.
//
Expand Down
1 change: 0 additions & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//!
//! For more details, see std::str

#![doc(primitive = "str")]
#![stable(feature = "rust1", since = "1.0.0")]

use self::pattern::Pattern;
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations on tuples
//! A finite heterogeneous sequence, `(T, U, ..)`
//!
//! To access a single element of a tuple one can use the `.0`
//! field access syntax.
Expand All @@ -28,7 +28,6 @@
//! * `Default`

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "tuple")]

use clone::Clone;
use cmp::*;
Expand Down
11 changes: 6 additions & 5 deletions src/librustc_unicode/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Character manipulation (`char` type, Unicode Scalar Value)
//! A Unicode scalar value
//!
//! This module provides the `CharExt` trait, as well as its
//! implementation for the primitive `char` type, in order to allow
//! basic character manipulation.
//!
//! A `char` actually represents a
//! *[Unicode Scalar
//! Value](http://www.unicode.org/glossary/#unicode_scalar_value)*, as it can
//! A `char` represents a
//! *[Unicode scalar
//! value](http://www.unicode.org/glossary/#unicode_scalar_value)*, as it can
//! contain any Unicode code point except high-surrogate and low-surrogate code
//! points.
//!
//! As such, only values in the ranges \[0x0,0xD7FF\] and \[0xE000,0x10FFFF\]
//! (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
//! however the converse is not always true due to the above range limits
//! and, as such, should be performed via the `from_u32` function.
//!
//! *[See also the `char` primitive type](../primitive.char.html).*

#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "char")]

use core::char::CharExt as C;
use core::option::Option::{self, Some, None};
Expand Down
55 changes: 0 additions & 55 deletions src/libstd/array.rs

This file was deleted.

Loading