D7866: rust-pathauditor: add Rust implementation of the `pathauditor`

kevincox (Kevin Cox) phabricator at mercurial-scm.org
Wed Jan 15 11:07:44 EST 2020


kevincox added inline comments.
kevincox accepted this revision.

INLINE COMMENTS

> path_auditor.rs:53
> +            .as_bytes()
> +            .split(|c| *c as char == std::path::MAIN_SEPARATOR)
> +            .collect();

Should this be `std::path::is_separator(*c as char)`?.

If not please add a comment explaining why.

> path_auditor.rs:54
> +            .split(|c| *c as char == std::path::MAIN_SEPARATOR)
> +            .collect();
> +        if !split_drive(path).0.is_empty()

It would be nice to have this in a helper function in path to get a component iterator.

> path_auditor.rs:72
> +                let last = split.next().unwrap();
> +                if last.iter().all(|b| (*b as char).is_digit(10))
> +                    && [&b"HG"[..], &b"HG8B6C"[..]].contains(&first.as_ref())

You can just use https://doc.rust-lang.org/std/primitive.u8.html#method.is_ascii_digit

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7866/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7866

To: Alphare, #hg-reviewers, kevincox
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list