Skip to content

Commit

Permalink
Changed to use from_utf8_lossy again (#4)
Browse files Browse the repository at this point in the history
The reason I changed to this before was that I couldn't get it working with the `Cow` object. Today, I checked the problem again and found the solution: `into_owned`, which takes ownership of the borrowed data (by copying it). Wonderful!

Also fixed a linting issue I happened to see when reading the Travis output.
  • Loading branch information
perlun authored Nov 26, 2016
1 parent 29899e0 commit 10bf5f4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![deny(unused_imports)]

use std::env;
use std::process::Command;
use std::process::exit;
use std::process::Output;

struct Changelog {
repository_path: String,
Expand Down Expand Up @@ -36,9 +37,7 @@ impl Changelog {
.current_dir(&self.repository_path)
.output()
.unwrap_or_else(|e| panic!("Failed to run 'git log' with error: {}", e));
unsafe {
String::from_utf8_unchecked(output.stdout)
}
String::from_utf8_lossy(&output.stdout).into_owned()
}

fn range(&self) -> String {
Expand Down

0 comments on commit 10bf5f4

Please sign in to comment.