2014-04-30 22:05:14 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-05-22 11:44:54 -05:00
|
|
|
//! # The Rust Core Library
|
2014-05-12 23:22:35 -05:00
|
|
|
//!
|
2014-05-19 23:53:00 -05:00
|
|
|
//! The Rust Core Library is the dependency-free foundation of [The
|
|
|
|
//! Rust Standard Library](../std/index.html). It is the portable glue
|
|
|
|
//! between the language and its libraries, defining the intrinsic and
|
|
|
|
//! primitive building blocks of all Rust code. It links to no
|
2014-05-20 13:39:40 -05:00
|
|
|
//! upstream libraries, no system libraries, and no libc.
|
2014-05-19 23:53:00 -05:00
|
|
|
//!
|
|
|
|
//! The core library is *minimal*: it isn't even aware of heap allocation,
|
|
|
|
//! nor does it provide concurrency or I/O. These things require
|
2014-05-20 13:39:40 -05:00
|
|
|
//! platform integration, and this library is platform-agnostic.
|
2014-05-19 23:53:00 -05:00
|
|
|
//!
|
|
|
|
//! *It is not recommended to use the core library*. The stable
|
|
|
|
//! functionality of libcore is reexported from the
|
|
|
|
//! [standard library](../std/index.html). The composition of this library is
|
|
|
|
//! subject to change over time; only the interface exposed through libstd is
|
|
|
|
//! intended to be stable.
|
|
|
|
//!
|
|
|
|
//! # How to use the core library
|
|
|
|
//!
|
2014-05-20 12:40:14 -05:00
|
|
|
// FIXME: Fill me in with more detail when the interface settles
|
2014-05-19 23:53:00 -05:00
|
|
|
//! This library is built on the assumption of a few existing symbols:
|
2014-05-12 23:22:35 -05:00
|
|
|
//!
|
|
|
|
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
|
|
|
|
//! often generated by LLVM. Additionally, this library can make explicit
|
2014-05-19 10:51:16 -05:00
|
|
|
//! calls to these functions. Their signatures are the same as found in C.
|
2014-05-14 13:24:12 -05:00
|
|
|
//! These functions are often provided by the system libc, but can also be
|
|
|
|
//! provided by `librlibc` which is distributed with the standard rust
|
|
|
|
//! distribution.
|
2014-05-12 23:22:35 -05:00
|
|
|
//!
|
|
|
|
//! * `rust_begin_unwind` - This function takes three arguments, a
|
2014-12-27 15:57:43 -06:00
|
|
|
//! `fmt::Arguments`, a `&str`, and a `uint`. These three arguments dictate
|
2014-10-09 14:17:22 -05:00
|
|
|
//! the panic message, the file at which panic was invoked, and the line.
|
|
|
|
//! It is up to consumers of this core library to define this panic
|
2014-05-12 23:22:35 -05:00
|
|
|
//! function; it is only required to never return.
|
2014-06-28 15:57:36 -05:00
|
|
|
|
|
|
|
// Since libcore defines many fundamental lang items, all tests live in a
|
|
|
|
// separate crate, libcoretest, to avoid bizarre issues.
|
2014-04-30 22:05:14 -05:00
|
|
|
|
2014-07-01 09:12:04 -05:00
|
|
|
#![crate_name = "core"]
|
2014-06-18 00:13:36 -05:00
|
|
|
#![experimental]
|
2014-04-30 22:05:14 -05:00
|
|
|
#![crate_type = "rlib"]
|
|
|
|
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
|
|
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
2014-10-09 12:47:22 -05:00
|
|
|
html_root_url = "http://doc.rust-lang.org/nightly/",
|
2014-06-06 11:12:18 -05:00
|
|
|
html_playground_url = "http://play.rust-lang.org/")]
|
2014-04-30 22:05:14 -05:00
|
|
|
|
|
|
|
#![no_std]
|
librustc: Make `Copy` opt-in.
This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.
A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.
For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.
This breaks code like:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
Change this code to:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
impl Copy for Point2D {}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
This is the backwards-incompatible part of #13231.
Part of RFC #3.
[breaking-change]
2014-12-05 19:01:33 -06:00
|
|
|
#![allow(unknown_features, raw_pointer_deriving)]
|
2014-10-01 16:19:55 -05:00
|
|
|
#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
|
2014-09-26 00:48:16 -05:00
|
|
|
#![feature(simd, unsafe_destructor, slicing_syntax)]
|
2014-12-12 21:58:48 -06:00
|
|
|
#![feature(default_type_params, unboxed_closures, associated_types)]
|
2014-10-27 17:37:07 -05:00
|
|
|
#![deny(missing_docs)]
|
2014-05-01 20:06:59 -05:00
|
|
|
|
2014-12-18 22:48:26 -06:00
|
|
|
#[cfg_attr(stage0, macro_escape)]
|
|
|
|
#[cfg_attr(not(stage0), macro_use)]
|
2014-05-01 12:47:18 -05:00
|
|
|
mod macros;
|
|
|
|
|
2014-12-18 22:09:57 -06:00
|
|
|
#[path = "num/float_macros.rs"]
|
2014-12-18 22:48:26 -06:00
|
|
|
#[cfg_attr(stage0, macro_escape)]
|
|
|
|
#[cfg_attr(not(stage0), macro_use)]
|
2014-12-18 22:09:57 -06:00
|
|
|
mod float_macros;
|
|
|
|
|
|
|
|
#[path = "num/int_macros.rs"]
|
2014-12-18 22:48:26 -06:00
|
|
|
#[cfg_attr(stage0, macro_escape)]
|
|
|
|
#[cfg_attr(not(stage0), macro_use)]
|
2014-12-18 22:09:57 -06:00
|
|
|
mod int_macros;
|
|
|
|
|
|
|
|
#[path = "num/uint_macros.rs"]
|
2014-12-18 22:48:26 -06:00
|
|
|
#[cfg_attr(stage0, macro_escape)]
|
|
|
|
#[cfg_attr(not(stage0), macro_use)]
|
2014-12-18 22:09:57 -06:00
|
|
|
mod uint_macros;
|
2014-05-01 00:23:26 -05:00
|
|
|
|
|
|
|
#[path = "num/int.rs"] pub mod int;
|
|
|
|
#[path = "num/i8.rs"] pub mod i8;
|
|
|
|
#[path = "num/i16.rs"] pub mod i16;
|
|
|
|
#[path = "num/i32.rs"] pub mod i32;
|
|
|
|
#[path = "num/i64.rs"] pub mod i64;
|
|
|
|
|
|
|
|
#[path = "num/uint.rs"] pub mod uint;
|
|
|
|
#[path = "num/u8.rs"] pub mod u8;
|
|
|
|
#[path = "num/u16.rs"] pub mod u16;
|
|
|
|
#[path = "num/u32.rs"] pub mod u32;
|
|
|
|
#[path = "num/u64.rs"] pub mod u64;
|
|
|
|
|
|
|
|
#[path = "num/f32.rs"] pub mod f32;
|
|
|
|
#[path = "num/f64.rs"] pub mod f64;
|
|
|
|
|
2014-05-01 00:14:22 -05:00
|
|
|
pub mod num;
|
|
|
|
|
2014-05-01 20:06:59 -05:00
|
|
|
/* The libcore prelude, not as all-encompassing as the libstd prelude */
|
|
|
|
|
|
|
|
pub mod prelude;
|
|
|
|
|
2014-04-30 22:04:56 -05:00
|
|
|
/* Core modules for ownership management */
|
|
|
|
|
|
|
|
pub mod intrinsics;
|
2014-04-30 22:13:05 -05:00
|
|
|
pub mod mem;
|
2014-12-11 21:29:24 -06:00
|
|
|
pub mod nonzero;
|
2014-04-30 22:17:50 -05:00
|
|
|
pub mod ptr;
|
2014-04-30 22:22:55 -05:00
|
|
|
|
|
|
|
/* Core language traits */
|
|
|
|
|
2015-01-05 19:03:46 -06:00
|
|
|
pub mod markers;
|
2014-06-28 15:57:36 -05:00
|
|
|
pub mod ops;
|
|
|
|
pub mod cmp;
|
2014-04-30 22:55:38 -05:00
|
|
|
pub mod clone;
|
2014-04-30 22:46:51 -05:00
|
|
|
pub mod default;
|
2014-04-30 22:33:08 -05:00
|
|
|
|
|
|
|
/* Core types and methods on primitives */
|
|
|
|
|
2014-04-30 22:36:58 -05:00
|
|
|
pub mod any;
|
2014-08-04 17:42:36 -05:00
|
|
|
pub mod atomic;
|
2014-11-12 14:01:26 -06:00
|
|
|
pub mod borrow;
|
2014-05-01 13:19:56 -05:00
|
|
|
pub mod cell;
|
|
|
|
pub mod char;
|
2014-10-09 14:17:22 -05:00
|
|
|
pub mod panicking;
|
2014-04-30 22:34:41 -05:00
|
|
|
pub mod finally;
|
2014-04-30 23:41:03 -05:00
|
|
|
pub mod iter;
|
2014-04-30 23:35:56 -05:00
|
|
|
pub mod option;
|
2014-04-30 22:38:31 -05:00
|
|
|
pub mod raw;
|
2014-05-01 01:25:35 -05:00
|
|
|
pub mod result;
|
2014-05-20 22:24:17 -05:00
|
|
|
pub mod simd;
|
2014-05-01 00:54:25 -05:00
|
|
|
pub mod slice;
|
2014-05-01 01:06:36 -05:00
|
|
|
pub mod str;
|
2014-12-12 20:43:07 -06:00
|
|
|
pub mod hash;
|
core: Inherit the std::fmt module
This commit moves all possible functionality from the standard library's string
formatting utilities into the core library. This is a breaking change, due to a
few tweaks in the semantics of formatting:
1. In order to break the dependency on the std::io module, a new trait,
FormatWriter was introduced in core::fmt. This is the trait which is used
(instead of Writer) to format data into a stream.
2. The new FormatWriter trait has one method, write(), which takes some bytes
and can return an error, but the error contains very little information. The
intent for this trait is for an adaptor writer to be used around the standard
library's Writer trait.
3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but
rather &mut FormatWriter. Since this trait is less common, all functions were
removed except fmt::write, and it is not intended to be invoked directly.
The main API-breaking change here is that the fmt::Formatter structure will no
longer expose its `buf` field. All previous code writing directly to `f.buf`
using writer methods or the `write!` macro will now instead use `f` directly.
The Formatter object itself implements the `Writer` trait itself for
convenience, although it does not implement the `FormatWriter` trait. The
fallout of these changes will be in the following commits.
[breaking-change]
2014-05-10 15:33:43 -05:00
|
|
|
pub mod fmt;
|
2014-05-01 01:19:52 -05:00
|
|
|
|
2014-10-31 04:41:25 -05:00
|
|
|
// note: does not need to be public
|
2014-12-18 21:13:32 -06:00
|
|
|
mod tuple;
|
2014-10-31 04:41:25 -05:00
|
|
|
mod array;
|
|
|
|
|
2014-05-29 11:58:09 -05:00
|
|
|
#[doc(hidden)]
|
2014-05-12 23:23:13 -05:00
|
|
|
mod core {
|
2014-10-09 14:17:22 -05:00
|
|
|
pub use panicking;
|
2014-09-15 21:29:47 -05:00
|
|
|
pub use fmt;
|
2014-05-12 23:23:13 -05:00
|
|
|
}
|
|
|
|
|
2014-05-29 11:58:09 -05:00
|
|
|
#[doc(hidden)]
|
2014-05-01 01:25:35 -05:00
|
|
|
mod std {
|
|
|
|
pub use clone;
|
|
|
|
pub use cmp;
|
2015-01-05 19:03:46 -06:00
|
|
|
#[cfg(stage0)]
|
|
|
|
pub use markers as kinds;
|
|
|
|
pub use markers;
|
core: Inherit the std::fmt module
This commit moves all possible functionality from the standard library's string
formatting utilities into the core library. This is a breaking change, due to a
few tweaks in the semantics of formatting:
1. In order to break the dependency on the std::io module, a new trait,
FormatWriter was introduced in core::fmt. This is the trait which is used
(instead of Writer) to format data into a stream.
2. The new FormatWriter trait has one method, write(), which takes some bytes
and can return an error, but the error contains very little information. The
intent for this trait is for an adaptor writer to be used around the standard
library's Writer trait.
3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but
rather &mut FormatWriter. Since this trait is less common, all functions were
removed except fmt::write, and it is not intended to be invoked directly.
The main API-breaking change here is that the fmt::Formatter structure will no
longer expose its `buf` field. All previous code writing directly to `f.buf`
using writer methods or the `write!` macro will now instead use `f` directly.
The Formatter object itself implements the `Writer` trait itself for
convenience, although it does not implement the `FormatWriter` trait. The
fallout of these changes will be in the following commits.
[breaking-change]
2014-05-10 15:33:43 -05:00
|
|
|
pub use option;
|
2014-05-11 13:14:14 -05:00
|
|
|
pub use fmt;
|
2014-12-12 20:43:07 -06:00
|
|
|
pub use hash;
|
2014-05-01 01:25:35 -05:00
|
|
|
}
|