Skip to content

Commit c58951e

Browse files
jesse99brson
authored andcommitted
Replace TmMut with inherited mutability
1 parent a9e1358 commit c58951e

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

src/libstd/time.rs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
155155
do_strptime(s, format)
156156
}
157157

158+
/// Formats the time according to the format string.
158159
pub fn strftime(format: &str, tm: Tm) -> ~str {
159160
do_strftime(format, tm)
160161
}
@@ -235,21 +236,6 @@ impl Tm {
235236
}
236237

237238
priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
238-
type TmMut = {
239-
mut tm_sec: i32,
240-
mut tm_min: i32,
241-
mut tm_hour: i32,
242-
mut tm_mday: i32,
243-
mut tm_mon: i32,
244-
mut tm_year: i32,
245-
mut tm_wday: i32,
246-
mut tm_yday: i32,
247-
mut tm_isdst: i32,
248-
mut tm_gmtoff: i32,
249-
mut tm_zone: ~str,
250-
mut tm_nsec: i32,
251-
};
252-
253239
fn match_str(s: &str, pos: uint, needle: &str) -> bool {
254240
let mut i = pos;
255241
for str::each(needle) |ch| {
@@ -312,7 +298,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
312298
}
313299
}
314300

315-
fn parse_type(s: &str, pos: uint, ch: char, tm: &TmMut)
301+
fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm_)
316302
-> Result<uint, ~str> {
317303
match ch {
318304
'A' => match match_strs(s, pos, ~[
@@ -623,19 +609,19 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
623609
}
624610

625611
do io::with_str_reader(str::from_slice(format)) |rdr| {
626-
let tm = {
627-
mut tm_sec: 0_i32,
628-
mut tm_min: 0_i32,
629-
mut tm_hour: 0_i32,
630-
mut tm_mday: 0_i32,
631-
mut tm_mon: 0_i32,
632-
mut tm_year: 0_i32,
633-
mut tm_wday: 0_i32,
634-
mut tm_yday: 0_i32,
635-
mut tm_isdst: 0_i32,
636-
mut tm_gmtoff: 0_i32,
637-
mut tm_zone: ~"",
638-
mut tm_nsec: 0_i32,
612+
let mut tm = {
613+
tm_sec: 0_i32,
614+
tm_min: 0_i32,
615+
tm_hour: 0_i32,
616+
tm_mday: 0_i32,
617+
tm_mon: 0_i32,
618+
tm_year: 0_i32,
619+
tm_wday: 0_i32,
620+
tm_yday: 0_i32,
621+
tm_isdst: 0_i32,
622+
tm_gmtoff: 0_i32,
623+
tm_zone: ~"",
624+
tm_nsec: 0_i32,
639625
};
640626
let mut pos = 0u;
641627
let len = str::len(s);
@@ -645,7 +631,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
645631
let {ch, next} = str::char_range_at(s, pos);
646632

647633
match rdr.read_char() {
648-
'%' => match parse_type(s, pos, rdr.read_char(), &tm) {
634+
'%' => match parse_type(s, pos, rdr.read_char(), &mut tm) {
649635
Ok(next) => pos = next,
650636
Err(copy e) => { result = Err(e); break; }
651637
},

0 commit comments

Comments
 (0)