Skip to content

Commit

Permalink
Fix windows clippy (#3)
Browse files Browse the repository at this point in the history
* Fix windows clippy

* fix

* debug

* fix

* minor
  • Loading branch information
j178 authored Oct 29, 2024
1 parent 624f5b3 commit 1155b9d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@ pub(crate) fn normalize_path(path: String) -> String {
/// Normalizes a path to use `/` as a separator everywhere, even on platforms
/// that recognize other characters as separators.
#[cfg(not(unix))]
pub(crate) fn normalize_path(mut path: String) -> String {
pub(crate) fn normalize_path(path: String) -> String {
use std::path::is_separator;

let bytes = unsafe { path.as_bytes_mut() };
for i in 0..bytes.len() {
if bytes[i] == b'/' || !is_separator(char::from(bytes[i])) {
let mut bytes = path.into_bytes();
for c in &mut bytes {
if *c == b'/' || !is_separator(char::from(*c)) {
continue;
}
bytes[i] = b'/';
*c = b'/';
}
path
String::from_utf8(bytes).expect("Path is valid UTF-8")
}

/// Compute a path describing `path` relative to `base`.
Expand Down

0 comments on commit 1155b9d

Please sign in to comment.