Skip to content

Commit

Permalink
Fix issue #55
Browse files Browse the repository at this point in the history
- This fixes an issue where we attempt to create a slice of bytes from a
string, assuming that two bytes doesn't end up in the middle of a
Unicode code point. Instead of comparing against the slice of bytes the
code now uses the String::starts_with() method to compare against the
same &str.
- Also adds a dev profile to Cargo.toml, which enables debug symbols and
turns down optimization.
  • Loading branch information
assarbad committed Oct 25, 2022
1 parent 56055f4 commit 88ea95b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ wild = "2"
[dev-dependencies]
assert_cmd = "1.0.1"
predicates = "1.0.5"

# xref: https://bitshifter.github.io/rr+rust/#11
# The development profile, used for `cargo build`
[profile.dev]
opt-level = 0 # Controls the --opt-level the compiler builds with
debug = true # Controls whether the compiler passes `-g`
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Rename {
// Expand ~ if applicable.
let mut new = new.to_string();
if let Ok(home) = env::var("HOME") {
if &new[..2] == "~/" {
if new.starts_with("~/") {
new = new.replacen("~", &home, 1);
}
}
Expand Down

0 comments on commit 88ea95b

Please sign in to comment.