D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

kevincox (Kevin Cox) phabricator at mercurial-scm.org
Wed Jul 10 10:53:02 EDT 2019


kevincox added a comment.
kevincox accepted this revision.


  Is the SliceExt change related to the 2018 change? If not could you split the two?

INLINE COMMENTS

> utils.rs:3
> +
> +pub fn replace_slice<T>(buf: &mut [T], from: &[T], to: &[T])
> +where

This could really use a doc comment.

> utils.rs:7
> +{
> +    if buf.len() < from.len() || from.len() != to.len() {
> +        return;

from.len() != to.len() sounds like a bug and I would probably use an `assert!()`. Unless this is expected to be common and "okay".

> utils.rs:12
> +        if buf[i..].starts_with(from) {
> +            buf[i..(i + from.len())].clone_from_slice(to);
> +        }

This allows overlapping replacements. I don't know if this is intended.

> utils.rs:38
> +    }
> +    fn trim_end(&self) -> &[u8] {
> +        if let Some(last) = self.iter().rposition(is_not_whitespace) {

Why not define `trim` as `self.trim_start().trim_end()`?

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list