D7791: rust-nodemap: NodeMap trait with simplest implementor

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Wed Jan 22 04:43:58 EST 2020


Alphare added inline comments.

INLINE COMMENTS

> martinvonz wrote in nodemap.rs:150
> > Alas, trait aliases are not stable: rust#55628.
> 
> I didn't know about trait aliases, but I think you can already do this:
> 
>   trait Thing : Deref<Target = [Block]> + Send  {}
> 
> 
> 
> > ... since this is a single occurrence in a private field, I find it reasonable.
> 
> It's one instance right now. It's 7 instances of `Box<dyn Deref<...>>` at the end of the series...

> I didn't know about trait aliases, but I think you can already do this:
>  `trait Thing : Deref<Target = [Block]> + Send  {}`

Using an empty supertrait will not work because fat pointers have different metadata.
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4f1d374e426c9791cbf73421160dc7c3

> It's one instance right now. It's 7 instances of Box<dyn Deref<...>> at the end of the series...

Ah true, that is indeed verbose, but manageable. Unfortunately, from a language perspective, I think that a type macro would be our only choice, but my opinion is that 1) it's ugly and more code to maintain and 2) I'm not even sure it would work.

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list