Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is Clone required for basically everything? #208

Open
jplatte opened this issue Feb 16, 2023 · 2 comments
Open

Why is Clone required for basically everything? #208

jplatte opened this issue Feb 16, 2023 · 2 comments

Comments

@jplatte
Copy link

jplatte commented Feb 16, 2023

I find it surprising that things like impl<A> Debug for Vector<A> require A: Clone. I have looked at the implementation and I'm pretty sure it should be possible to loosen Clone trait bounds in many places. Would PRs for that be welcome?

@bitcoin-eagle
Copy link

just read the doc https://docs.rs/im/latest/im/#when-does-cloning-happen . TLDR Clone of small-ish values is faster than alternatives and if you have big values just use Rc<...> or Arc<...> where it clones just the pointer

It cannot be changed without complete redesign. It has optimized like this for a reason that there are small opportunistic arrays that get cloned when needed

@jplatte
Copy link
Author

jplatte commented Aug 19, 2023

It can be changed. imbl, which is a maintained fork of im, implements some of the required changes (I recently contributed some myself). Note that I am not asking to make Vector<T> a properly usable type that values can be pushed to / that can be cloned or whatever. I just want to be able to drive Debug for a generic type that holds Vector<T> (which I have done successfully, since switching to imbl).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants