Skip to content

Attempt to simplify ZeroCopyFrom #1255

Closed
@Manishearth

Description

@Manishearth

Currently ZeroCopyFrom has the following signature:

pub trait ZeroCopyFrom<C: ?Sized>: for<'a> Yokeable<'a> {
    fn zero_copy_from<'b>(cart: &'b C) -> <Self as Yokeable<'b>>::Output;
}

impl<'data> ZeroCopyFrom<Foo<'data>> for Foo<'static> { .. }

It's supposed to be implemented on 'static types.

For its original purpose of helping attach_to_foo_cart() functions, it makes a lot of sense (this is why it derives from Yokeable) but there are a couple problems:

  • Since the 'static type doesn't show up in a lot of places, you really need to use a lot of explicit typing and UFCS to make stuff compile
  • Stuff like Should we have FromVarULE? #1180 can't use it

It might be better to do this instead:

pub trait ZeroCopyFrom<'data, C: ?Sized> {
    fn zero_copy_from<'data>(cart: &'data C) -> Self;
}

impl<'a, 'b: 'a> ZeroCopyFrom<'b, Foo<'b>> for Foo<'a> { .. }

If we can make this work with all of the signatures in use. There may be some need of for<'b> ZCF<'b>.

Discussed a bit with @sffc , I plan to investigate this

Metadata

Metadata

Labels

C-data-infraComponent: provider, datagen, fallback, adaptersS-mediumSize: Less than a week (larger bug fix or enhancement)T-techdebtType: ICU4X code health and tech debt

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions