diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-06-07 14:25:06 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-06-07 14:25:06 +0200 |
commit | bfa6f593b63192db6cc9f624a0380b91004eaf56 (patch) | |
tree | 11b9a05ef0b1f8d813b1412dc4d3a6aa0c24a522 /libimagrt | |
parent | 88e89d79274e3047936852228a7bb6617ec40ad8 (diff) |
Fix: Re-writing content of String in edit_in_tmpfile()
Diffstat (limited to 'libimagrt')
-rw-r--r-- | libimagrt/src/edit.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libimagrt/src/edit.rs b/libimagrt/src/edit.rs index 67f495b8..b04bec06 100644 --- a/libimagrt/src/edit.rs +++ b/libimagrt/src/edit.rs @@ -61,7 +61,12 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> EditResult<()> { Ok(true) => { file.sync_data() .and_then(|_| file.seek(SeekFrom::Start(0))) - .and_then(|_| file.read_to_string(s)) + .and_then(|_| { + let mut new_s = String::new(); + let res = file.read_to_string(&mut new_s); + *s = new_s; + res + }) .map(|_| ()) .map_err(Box::new) .map_err(|e| RuntimeErrorKind::IOError.into_error_with_cause(e)) |