yewstack / implicit-clone

Immutable types and ImplicitClone trait similar to Copy
19 stars 10 forks source link

Implement ImplicitClone for char #16

Closed cecton closed 1 year ago

cecton commented 1 year ago

Any primitive type that implements Copy should also implement ImplicitClone. It would be nice if it was possible to tell Rust that but I couldn't manage to do it. If anyone wants to give it a try...

https://github.com/yewstack/implicit-clone/pull/9#issuecomment-1198598528

In the meantime, here is a small PR for adding char so it's possible to make a type IArray<char>.

cecton commented 1 year ago

@WorldSEnder yes you're mixing up with IntoPropValue I think.

In Yew, ImplicitClone allows giving references to props so they are automatically cloned. For example:

let Props { my_array: list } = &ctx.props();

// ...

<ListComponent {list} />

(so ImplicitClone extends over Copy as more type can be implicitly cloned)

Adding primitives to ImplicitClone allows nesting types because IArray<T> requires that T: ImplicitClone.

It's not exactly the same use case.

cecton commented 1 year ago

Merging this for now before I forget that PR exists lol