Skip to content

Commit 35ab70d

Browse files
committed
---
yaml --- r: 63421 b: refs/heads/snap-stage3 c: 90b999a h: refs/heads/master i: 63419: f68ebb1 v: v3
1 parent 5e5e23e commit 35ab70d

File tree

7 files changed

+68
-30
lines changed

7 files changed

+68
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 5acc8e5a51e97a6ab5f0aaceedefcf8cd10a0c1b
4+
refs/heads/snap-stage3: 90b999aea1a4cfdda549c2ba8462d9eac23c681a
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Source layout:
44

55
librustc/ The self-hosted compiler
66

7-
libstd/ The standard library (imported and linked by default)
8-
libextra/ The "extras" library (slightly more peripheral code)
7+
libcore/ The core library (imported and linked by default)
8+
libstd/ The standard library (slightly more peripheral code)
99
libsyntax/ The Rust parser and pretty-printer
1010

1111
rt/ The runtime system

branches/snap-stage3/src/libextra/std.rc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,19 @@
1010

1111
/*!
1212

13-
Rust extras.
13+
The Rust standard library.
1414

15-
The `extra` crate is a set of useful modules for a variety of
16-
purposes, including collections, numerics, I/O, serialization,
17-
and concurrency.
18-
19-
Rust extras are part of the standard Rust distribution.
15+
The Rust standand library provides a number of useful features that are
16+
not required in or otherwise suitable for the core library.
2017

2118
*/
2219

2320
#[link(name = "extra",
2421
vers = "0.7-pre",
2522
uuid = "122bed0b-c19b-4b82-b0b7-7ae8aead7297",
26-
url = "https://github.com/mozilla/rust/tree/master/src/libextra")];
23+
url = "https://github.com/mozilla/rust/tree/master/src/libstd")];
2724

28-
#[comment = "Rust extras"];
25+
#[comment = "The Rust standard library"];
2926
#[license = "MIT/ASL2"];
3027
#[crate_type = "lib"];
3128

@@ -131,7 +128,7 @@ pub mod test;
131128
pub mod serialize;
132129

133130
// A curious inner-module that's not exported that contains the binding
134-
// 'extra' so that macro-expanded references to extra::serialize and such
131+
// 'extra' so that macro-expanded references to std::serialize and such
135132
// can be resolved within libextra.
136133
#[doc(hidden)]
137134
pub mod std {

branches/snap-stage3/src/libstd/core.rc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212

1313
# The Rust standard library
1414

15-
The Rust standard library is a group of interrelated modules defining
16-
the core language traits, operations on built-in data types, collections,
17-
platform abstractions, the task scheduler, runtime support for language
18-
features and other common functionality.
19-
20-
`std` includes modules corresponding to each of the integer types,
21-
each of the floating point types, the `bool` type, tuples, characters,
22-
strings (`str`), vectors (`vec`), managed boxes (`managed`), owned
23-
boxes (`owned`), and unsafe and borrowed pointers (`ptr`, `borrowed`).
24-
Additionally, `std` provides pervasive types (`option` and `result`),
25-
task creation and communication primitives (`task`, `comm`), platform
26-
abstractions (`os` and `path`), basic I/O abstractions (`io`), common
27-
traits (`kinds`, `ops`, `cmp`, `num`, `to_str`), and complete bindings
28-
to the C standard library (`libc`).
15+
The Rust standard library provides runtime features required by the language,
16+
including the task scheduler and memory allocators, as well as library
17+
support for Rust built-in types, platform abstractions, and other commonly
18+
used features.
19+
20+
`std` includes modules corresponding to each of the integer types, each of
21+
the floating point types, the `bool` type, tuples, characters, strings
22+
(`str`), vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`),
23+
and unsafe and borrowed pointers (`ptr`). Additionally, `std` provides
24+
pervasive types (`option` and `result`), task creation and communication
25+
primitives (`task`, `comm`), platform abstractions (`os` and `path`), basic
26+
I/O abstractions (`io`), common traits (`kinds`, `ops`, `cmp`, `num`,
27+
`to_str`), and complete bindings to the C standard library (`libc`).
2928

3029
# Standard library injection and the Rust prelude
3130

@@ -39,7 +38,7 @@ with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
3938
etc.
4039

4140
Additionally, `std` contains a `prelude` module that reexports many of the
42-
most common types, traits and functions. The contents of the prelude are
41+
most common std modules, types and traits. The contents of the prelude are
4342
imported into every *module* by default. Implicitly, all modules behave as if
4443
they contained the following prologue:
4544

@@ -67,7 +66,7 @@ they contained the following prologue:
6766
#[deny(non_camel_case_types)];
6867
#[deny(missing_doc)];
6968

70-
// Make std testable by not duplicating lang items. See #2912
69+
// Make core testable by not duplicating lang items. See #2912
7170
#[cfg(test)] extern mod realstd(name = "std");
7271
#[cfg(test)] pub use kinds = realstd::kinds;
7372
#[cfg(test)] pub use ops = realstd::ops;

branches/snap-stage3/src/libstd/libc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* This module contains bindings to the C standard library,
1515
* organized into modules by their defining standard.
1616
* Additionally, it contains some assorted platform-specific definitions.
17-
* For convenience, most functions and types are reexported from `std::libc`,
18-
* so `pub use std::libc::*` will import the available
17+
* For convenience, most functions and types are reexported from `core::libc`,
18+
* so `pub use core::libc::*` will import the available
1919
* C bindings as appropriate for the target platform. The exact
2020
* set of functions available are platform specific.
2121
*

branches/snap-stage3/src/libstd/str.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,12 @@ impl<'self> Iterator<u8> for StrBytesRevIterator<'self> {
22022202
}
22032203
}
22042204
2205+
// This works because every lifetime is a sub-lifetime of 'static
2206+
impl<'self> Zero for &'self str {
2207+
fn zero() -> &'self str { "" }
2208+
fn is_zero(&self) -> bool { self.is_empty() }
2209+
}
2210+
22052211
impl Zero for ~str {
22062212
fn zero() -> ~str { ~"" }
22072213
fn is_zero(&self) -> bool { self.len() == 0 }
@@ -3317,4 +3323,18 @@ mod tests {
33173323
t("zzz", "zz", ~["","z"]);
33183324
t("zzzzz", "zz", ~["","","z"]);
33193325
}
3326+
3327+
#[test]
3328+
fn test_str_zero() {
3329+
use num::Zero;
3330+
fn t<S: Zero + Str>() {
3331+
let s: S = Zero::zero();
3332+
assert_eq!(s.as_slice(), "");
3333+
assert!(s.is_zero());
3334+
}
3335+
3336+
t::<&str>();
3337+
t::<@str>();
3338+
t::<~str>();
3339+
}
33203340
}

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,12 @@ impl<A:Clone> Clone for ~[A] {
26292629
}
26302630
}
26312631

2632+
// This works because every lifetime is a sub-lifetime of 'static
2633+
impl<'self, A> Zero for &'self [A] {
2634+
fn zero() -> &'self [A] { &'self [] }
2635+
fn is_zero(&self) -> bool { self.is_empty() }
2636+
}
2637+
26322638
impl<A> Zero for ~[A] {
26332639
fn zero() -> ~[A] { ~[] }
26342640
fn is_zero(&self) -> bool { self.len() == 0 }
@@ -4293,4 +4299,20 @@ mod tests {
42934299
}
42944300
assert_eq!(v, ~[~[1,2,3],~[1,3,2],~[2,1,3],~[2,3,1],~[3,1,2],~[3,2,1]]);
42954301
}
4302+
4303+
#[test]
4304+
fn test_vec_zero() {
4305+
use num::Zero;
4306+
macro_rules! t (
4307+
($ty:ty) => {
4308+
let v: $ty = Zero::zero();
4309+
assert!(v.is_empty());
4310+
assert!(v.is_zero());
4311+
}
4312+
);
4313+
4314+
t!(&[int]);
4315+
t!(@[int]);
4316+
t!(~[int]);
4317+
}
42964318
}

0 commit comments

Comments
 (0)