Skip to content

Commit f46c46a

Browse files
committed
---
yaml --- r: 73704 b: refs/heads/dist-snap c: e1c1c05 h: refs/heads/master v: v3
1 parent dde8471 commit f46c46a

File tree

4 files changed

+39
-37
lines changed

4 files changed

+39
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 34ee63e93bd763326e676bd634f6f17a8f77791d
10+
refs/heads/dist-snap: e1c1c059c6d120d324a0a2d5125363c21ad11940
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/flatpipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ mod test {
660660
#[test]
661661
#[ignore(reason = "ebml failure")]
662662
fn test_serializing_memory_stream() {
663-
let writer = BytesWriter();
663+
let writer = BytesWriter::new();
664664
let chan = serial::writer_chan(writer);
665665

666666
chan.send(10);
@@ -708,7 +708,7 @@ mod test {
708708

709709
#[test]
710710
fn test_pod_memory_stream() {
711-
let writer = BytesWriter();
711+
let writer = BytesWriter::new();
712712
let chan = pod::writer_chan(writer);
713713

714714
chan.send(10);

branches/dist-snap/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ pub static metadata_encoding_version : &'static [u8] =
14251425
0, 0, 0, 1 ];
14261426

14271427
pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
1428-
let wr = @io::BytesWriter();
1428+
let wr = @io::BytesWriter::new();
14291429
let stats = Stats {
14301430
inline_bytes: 0,
14311431
attr_bytes: 0,

branches/dist-snap/src/libstd/io.rs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,12 @@ pub struct FILERes {
982982
f: *libc::FILE,
983983
}
984984

985+
impl FILERes {
986+
pub fn new(f: *libc::FILE) -> FILERes {
987+
FILERes { f: f }
988+
}
989+
}
990+
985991
impl Drop for FILERes {
986992
fn finalize(&self) {
987993
unsafe {
@@ -990,15 +996,9 @@ impl Drop for FILERes {
990996
}
991997
}
992998

993-
pub fn FILERes(f: *libc::FILE) -> FILERes {
994-
FILERes {
995-
f: f
996-
}
997-
}
998-
999999
pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
10001000
if cleanup {
1001-
@Wrapper { base: f, cleanup: FILERes(f) } as @Reader
1001+
@Wrapper { base: f, cleanup: FILERes::new(f) } as @Reader
10021002
} else {
10031003
@f as @Reader
10041004
}
@@ -1183,7 +1183,7 @@ impl Writer for *libc::FILE {
11831183

11841184
pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
11851185
if cleanup {
1186-
@Wrapper { base: f, cleanup: FILERes(f) } as @Writer
1186+
@Wrapper { base: f, cleanup: FILERes::new(f) } as @Writer
11871187
} else {
11881188
@f as @Writer
11891189
}
@@ -1227,6 +1227,12 @@ pub struct FdRes {
12271227
fd: fd_t,
12281228
}
12291229

1230+
impl FdRes {
1231+
pub fn new(fd: fd_t) -> FdRes {
1232+
FdRes { fd: fd }
1233+
}
1234+
}
1235+
12301236
impl Drop for FdRes {
12311237
fn finalize(&self) {
12321238
unsafe {
@@ -1235,15 +1241,9 @@ impl Drop for FdRes {
12351241
}
12361242
}
12371243

1238-
pub fn FdRes(fd: fd_t) -> FdRes {
1239-
FdRes {
1240-
fd: fd
1241-
}
1242-
}
1243-
12441244
pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
12451245
if cleanup {
1246-
@Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer
1246+
@Wrapper { base: fd, cleanup: FdRes::new(fd) } as @Writer
12471247
} else {
12481248
@fd as @Writer
12491249
}
@@ -1634,6 +1634,15 @@ pub struct BytesWriter {
16341634
pos: @mut uint,
16351635
}
16361636

1637+
impl BytesWriter {
1638+
pub fn new() -> BytesWriter {
1639+
BytesWriter {
1640+
bytes: @mut ~[],
1641+
pos: @mut 0
1642+
}
1643+
}
1644+
}
1645+
16371646
impl Writer for BytesWriter {
16381647
fn write(&self, v: &[u8]) {
16391648
let v_len = v.len();
@@ -1673,15 +1682,8 @@ impl Writer for BytesWriter {
16731682
}
16741683
}
16751684

1676-
pub fn BytesWriter() -> BytesWriter {
1677-
BytesWriter {
1678-
bytes: @mut ~[],
1679-
pos: @mut 0
1680-
}
1681-
}
1682-
16831685
pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
1684-
let wr = @BytesWriter();
1686+
let wr = @BytesWriter::new();
16851687
f(wr as @Writer);
16861688
let @BytesWriter { bytes, _ } = wr;
16871689
copy *bytes
@@ -1762,6 +1764,12 @@ pub mod fsync {
17621764
arg: Arg<t>,
17631765
}
17641766

1767+
impl <t: Copy> Res<t> {
1768+
pub fn new(arg: Arg<t>) -> Res<t> {
1769+
Res { arg: arg }
1770+
}
1771+
}
1772+
17651773
#[unsafe_destructor]
17661774
impl<T:Copy> Drop for Res<T> {
17671775
fn finalize(&self) {
@@ -1776,12 +1784,6 @@ pub mod fsync {
17761784
}
17771785
}
17781786

1779-
pub fn Res<t: Copy>(arg: Arg<t>) -> Res<t>{
1780-
Res {
1781-
arg: arg
1782-
}
1783-
}
1784-
17851787
pub struct Arg<t> {
17861788
val: t,
17871789
opt_level: Option<Level>,
@@ -1793,7 +1795,7 @@ pub mod fsync {
17931795
// outer res
17941796
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
17951797
blk: &fn(v: Res<*libc::FILE>)) {
1796-
blk(Res(Arg {
1798+
blk(Res::new(Arg {
17971799
val: file.f, opt_level: opt_level,
17981800
fsync_fn: |file, l| {
17991801
unsafe {
@@ -1806,7 +1808,7 @@ pub mod fsync {
18061808
// fsync fd after executing blk
18071809
pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
18081810
blk: &fn(v: Res<fd_t>)) {
1809-
blk(Res(Arg {
1811+
blk(Res::new(Arg {
18101812
val: fd.fd, opt_level: opt_level,
18111813
fsync_fn: |fd, l| os::fsync_fd(fd, l) as int
18121814
}));
@@ -1818,7 +1820,7 @@ pub mod fsync {
18181820
// Call o.fsync after executing blk
18191821
pub fn obj_sync(o: @FSyncable, opt_level: Option<Level>,
18201822
blk: &fn(v: Res<@FSyncable>)) {
1821-
blk(Res(Arg {
1823+
blk(Res::new(Arg {
18221824
val: o, opt_level: opt_level,
18231825
fsync_fn: |o, l| o.fsync(l)
18241826
}));
@@ -1993,7 +1995,7 @@ mod tests {
19931995
19941996
#[test]
19951997
fn bytes_buffer_overwrite() {
1996-
let wr = BytesWriter();
1998+
let wr = BytesWriter::new();
19971999
wr.write([0u8, 1u8, 2u8, 3u8]);
19982000
assert!(*wr.bytes == ~[0u8, 1u8, 2u8, 3u8]);
19992001
wr.seek(-2, SeekCur);

0 commit comments

Comments
 (0)