Skip to content

Removed slice <-> view distinction in vec and str #5466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
let start_kind = idx;
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
let kind = str::to_lower(str::slice(line, start_kind, idx));
let kind = str::to_lower(str::slice(line, start_kind, idx).to_owned());

// Extract msg:
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
let msg = str::slice(line, idx, len);
let msg = str::slice(line, idx, len).to_owned();

debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);

Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn parse_name_value_directive(line: ~str,
match str::find_str(line, keycolon) {
Some(colon) => {
let value = str::slice(line, colon + str::len(keycolon),
str::len(line));
str::len(line)).to_owned();
debug!("%s: %s", directive, value);
Some(value)
}
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/num/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,14 @@ pub pure fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+

// only resize buf if we actually remove digits
if i < buf_max_i {
buf = buf.slice(0, i + 1);
buf = buf.slice(0, i + 1).to_owned();
}
}
} // If exact and trailing '.', just cut that
else {
let max_i = buf.len() - 1;
if buf[max_i] == '.' as u8 {
buf = buf.slice(0, max_i);
buf = buf.slice(0, max_i).to_owned();
}
}

Expand Down Expand Up @@ -606,7 +606,7 @@ pub pure fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
// parse remaining bytes as decimal integer,
// skipping the exponent char
let exp: Option<int> = from_str_bytes_common(
buf.view(i+1, len), 10, true, false, false, ExpNone, false);
buf.slice(i+1, len), 10, true, false, false, ExpNone, false);

match exp {
Some(exp_pow) => {
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl GenericPath for PosixPath {
None => None,
Some(ref f) => {
match str::rfind_char(*f, '.') {
Some(p) => Some(f.slice(0, p)),
Some(p) => Some(f.slice(0, p).to_owned()),
None => Some(copy *f)
}
}
Expand All @@ -422,7 +422,7 @@ impl GenericPath for PosixPath {
None => None,
Some(ref f) => {
match str::rfind_char(*f, '.') {
Some(p) if p < f.len() => Some(f.slice(p, f.len())),
Some(p) if p < f.len() => Some(f.slice(p, f.len()).to_owned()),
_ => None
}
}
Expand Down Expand Up @@ -622,7 +622,7 @@ impl GenericPath for WindowsPath {
None => None,
Some(ref f) => {
match str::rfind_char(*f, '.') {
Some(p) => Some(f.slice(0, p)),
Some(p) => Some(f.slice(0, p).to_owned()),
None => Some(copy *f)
}
}
Expand All @@ -634,7 +634,7 @@ impl GenericPath for WindowsPath {
None => None,
Some(ref f) => {
match str::rfind_char(*f, '.') {
Some(p) if p < f.len() => Some(f.slice(p, f.len())),
Some(p) if p < f.len() => Some(f.slice(p, f.len()).to_owned()),
_ => None
}
}
Expand Down Expand Up @@ -842,8 +842,8 @@ pub mod windows {
let mut i = 2;
while i < s.len() {
if is_sep(s[i]) {
let pre = s.slice(2, i);
let mut rest = s.slice(i, s.len());
let pre = s.slice(2, i).to_owned();
let mut rest = s.slice(i, s.len()).to_owned();
return Some((pre, rest));
}
i += 1;
Expand All @@ -860,9 +860,9 @@ pub mod windows {
let rest = if s.len() == 2 {
~""
} else {
s.slice(2, s.len())
s.slice(2, s.len()).to_owned()
};
return Some((s.slice(0,1), rest));
return Some((s.slice(0,1).to_owned(), rest));
}
None
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/rt/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ fn listen() {
if status.is_none() {
rtdebug!("got %d bytes", nread);
let buf = buf.unwrap();
for buf.view(0, nread as uint).each |byte| {
for buf.slice(0, nread as uint).each |byte| {
fail_unless!(*byte == count as u8);
rtdebug!("%u", *byte as uint);
count += 1;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fn read_all(rd: io::Reader) -> ~str {
let mut bytes = [0, ..4096];
while !rd.eof() {
let nread = rd.read(bytes, bytes.len());
wr.write(bytes.view(0, nread));
wr.write(bytes.slice(0, nread));
}
});
str::from_bytes(buf)
Expand Down Expand Up @@ -404,7 +404,7 @@ pub fn readclose(fd: c_int) -> ~str {
let mut bytes = [0, ..4096];
while !reader.eof() {
let nread = reader.read(bytes, bytes.len());
writer.write(bytes.view(0, nread));
writer.write(bytes.slice(0, nread));
}
});
os::fclose(file);
Expand Down
Loading