Skip to content

Commit e74db94

Browse files
committed
---
yaml --- r: 49470 b: refs/heads/master c: 5f2d410 h: refs/heads/master v: v3
1 parent f6356f7 commit e74db94

File tree

23 files changed

+321
-378
lines changed

23 files changed

+321
-378
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e7dbe6cd6f40b5360d6121ce9dba9803f2cf3233
2+
refs/heads/master: 5f2d4102c5dabde915f1f6cb99c38b9274790cda
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea

trunk/doc/tutorial.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,21 +579,30 @@ Structs are quite similar to C structs and are even laid out the same way in
579579
memory (so you can read from a Rust struct in C, and vice-versa). Use the dot
580580
operator to access struct fields, as in `mypoint.x`.
581581

582-
Inherited mutability means that any field of a struct may be mutable, if the
583-
struct is in a mutable slot (or a field of a struct in a mutable slot, and
584-
so forth).
585-
586582
~~~~
587-
struct Stack {
588-
content: ~[int],
589-
head: uint
583+
struct Point {
584+
x: float,
585+
y: float
590586
}
591587
~~~~
592588

593-
With a value (say, `mystack`) of such a type in a mutable location, you can do
594-
`mystack.head += 1`. But in an immutable location, such an assignment to a
589+
Inherited mutability means that any field of a struct may be mutable, if the
590+
struct is in a mutable slot (or a field of a struct in a mutable slot, and
591+
so forth).
592+
593+
With a value (say, `mypoint`) of such a type in a mutable location, you can do
594+
`mypoint.y += 1.0`. But in an immutable location, such an assignment to a
595595
struct without inherited mutability would result in a type error.
596596

597+
~~~~ {.xfail-test}
598+
# struct Point { x: float, y: float }
599+
let mut mypoint = Point { x: 1.0, y: 1.0 };
600+
let origin = Point { x: 0.0, y: 0.0 };
601+
602+
mypoint.y += 1.0; // mypoint is mutable, and its fields as well
603+
origin.y += 1.0; // ERROR: assigning to immutable field
604+
~~~~
605+
597606
`match` patterns destructure structs. The basic syntax is
598607
`Name { fieldname: pattern, ... }`:
599608

trunk/src/libcore/comm.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
108108
109109
// Add an inherent method so that imports of GenericChan are not
110110
// required.
111+
#[cfg(stage1)]
112+
#[cfg(stage2)]
113+
#[cfg(stage3)]
111114
pub impl<T: Owned> Chan<T> {
112115
fn send(&self, x: T) { chan_send(self, x) }
113116
fn try_send(&self, x: T) -> bool { chan_try_send(self, x) }
@@ -145,6 +148,9 @@ fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
145148
}
146149
147150
// Use an inherent impl so that imports are not required:
151+
#[cfg(stage1)]
152+
#[cfg(stage2)]
153+
#[cfg(stage3)]
148154
pub impl<T: Owned> Port<T> {
149155
fn recv(&self) -> T { port_recv(self) }
150156
fn try_recv(&self) -> Option<T> { port_try_recv(self) }
@@ -220,6 +226,9 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
220226
}
221227
222228
// Use an inherent impl so that imports are not required:
229+
#[cfg(stage1)]
230+
#[cfg(stage2)]
231+
#[cfg(stage3)]
223232
pub impl<T:Owned> PortSet<T> {
224233
fn recv(&self) -> T { port_set_recv(self) }
225234
fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }
@@ -293,6 +302,9 @@ pure fn port_set_peek<T:Owned>(self: &PortSet<T>) -> bool {
293302
/// A channel that can be shared between many senders.
294303
pub type SharedChan<T> = unstable::Exclusive<Chan<T>>;
295304
305+
#[cfg(stage1)]
306+
#[cfg(stage2)]
307+
#[cfg(stage3)]
296308
pub impl<T: Owned> SharedChan<T> {
297309
fn send(&self, x: T) { shared_chan_send(self, x) }
298310
fn try_send(&self, x: T) -> bool { shared_chan_try_send(self, x) }

trunk/src/libcore/core.rc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub use path::WindowsPath;
198198
pub use path::PosixPath;
199199

200200
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
201-
pub use str::{StrSlice, Trimmable};
201+
pub use str::{StrSlice};
202202
pub use container::{Container, Mutable};
203203
pub use vec::{CopyableVector, ImmutableVector};
204204
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
@@ -212,10 +212,34 @@ pub use to_str::ToStr;
212212
pub use clone::Clone;
213213

214214

215+
/*
216+
* Export the log levels as global constants. Higher levels mean
217+
* more-verbosity. Error is the bottom level, default logging level is
218+
* warn-and-below.
219+
*/
220+
/// The error log level
221+
#[cfg(stage0)]
222+
pub const error : u32 = 1_u32;
223+
/// The warning log level
224+
#[cfg(stage0)]
225+
pub const warn : u32 = 2_u32;
226+
/// The info log level
227+
#[cfg(stage0)]
228+
pub const info : u32 = 3_u32;
229+
/// The debug log level
230+
#[cfg(stage0)]
231+
pub const debug : u32 = 4_u32;
232+
233+
215234
/* Unsupported interfaces */
216235

217236
// Private APIs
218237
pub mod unstable;
238+
// NOTE: Remove after snapshot
239+
#[cfg(stage0)]
240+
pub mod private {
241+
pub use super::unstable::extfmt;
242+
}
219243

220244
/* For internal use, not exported */
221245

@@ -231,6 +255,15 @@ pub mod rt;
231255
// can be resolved within libcore.
232256
#[doc(hidden)]
233257
pub mod core {
258+
#[cfg(stage0)]
259+
pub const error : u32 = 1_u32;
260+
#[cfg(stage0)]
261+
pub const warn : u32 = 2_u32;
262+
#[cfg(stage0)]
263+
pub const info : u32 = 3_u32;
264+
#[cfg(stage0)]
265+
pub const debug : u32 = 4_u32;
266+
234267
pub use cmp;
235268
pub use condition;
236269
pub use option;

trunk/src/libcore/io.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub trait Reader {
7575
fn tell(&self) -> uint;
7676
}
7777

78+
#[cfg(stage1)]
79+
#[cfg(stage2)]
80+
#[cfg(stage3)]
7881
impl Reader for @Reader {
7982
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
8083
self.read(bytes, len)
@@ -655,6 +658,9 @@ pub trait Writer {
655658
fn get_type(&self) -> WriterType;
656659
}
657660
661+
#[cfg(stage1)]
662+
#[cfg(stage2)]
663+
#[cfg(stage3)]
658664
impl Writer for @Writer {
659665
fn write(&self, v: &[const u8]) { self.write(v) }
660666
fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }

trunk/src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use path::Path;
3636
pub use path::PosixPath;
3737
pub use path::WindowsPath;
3838
pub use ptr::Ptr;
39-
pub use str::{StrSlice, Trimmable, OwnedStr};
39+
pub use str::{StrSlice, OwnedStr};
4040
pub use to_bytes::IterBytes;
4141
pub use to_str::ToStr;
4242
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};

0 commit comments

Comments
 (0)