Skip to content

Commit 7294422

Browse files
committed
Cleanup env
1 parent e683933 commit 7294422

File tree

1 file changed

+5
-4
lines changed
  • src/libstd/sys/redox

1 file changed

+5
-4
lines changed

src/libstd/sys/redox/os.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ pub fn env() -> Env {
144144
let mut string = String::new();
145145
if file.read_to_string(&mut string).is_ok() {
146146
for line in string.lines() {
147-
if let Some(equal_sign) = line.chars().position(|c| c == '=') {
148-
let name = line.chars().take(equal_sign).collect::<String>();
149-
let value = line.chars().skip(equal_sign+1).collect::<String>();
150-
variables.push((OsString::from(name), OsString::from(value)));
147+
let mut parts = line.splitn(2, '=');
148+
if let Some(name) = parts.next() {
149+
let value = parts.next().unwrap_or("");
150+
variables.push((OsString::from(name.to_string()),
151+
OsString::from(value.to_string())));
151152
}
152153
}
153154
}

0 commit comments

Comments
 (0)