D7790: rust-node: handling binary Node prefix

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Jan 21 12:55:38 EST 2020


martinvonz added inline comments.

INLINE COMMENTS

> node.rs:79
> +        let is_odd = len % 2 == 1;
> +        let mut buf: Vec<u8> = Vec::with_capacity(20);
> +        for i in 0..len / 2 {

Why not use `(len + 1) / 2` as capacity?

> node.rs:89
> +
> +    pub fn borrow<'a>(&'a self) -> NodePrefixRef<'a> {
> +        NodePrefixRef {

Is this lifetime parameter needed?

> node.rs:136
> +        NodePrefixRef {
> +            buf: &*node,
> +            is_odd: false,

What does the `&*` do? Specifically, what's different if you drop that part?

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list