D7864: rust-utils: add Rust implementation of Python's "os.path.splitdrive"

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


kevincox added inline comments.

INLINE COMMENTS

> Alphare wrote in files.rs:109
> Indeed, this is much better. While trying to adapt this code to fit with `HgPath`, I find myself needing to translate to and from bytes whenever indexing or when using `split_at`. Should we give a `HgPath` a `split_at` method or also all the `Index<>` ones? I remember that we decided against that earlier.

I would recommend just converting to bytes at the top of the function then converting the return value to a path at the exit. I feel when you are doing manipulation like this it makes the most sense to treat it as plain bytes within the function.

Alternatively I wouldn't mind putting an index operator but have a slight preference for `path.as_bytes()[n]` to keep it explicit as most of the code shouldn't be reaching into paths.

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list