Skip to content

Possibly add utility extension traits for quick conversion into immutable types #57

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

Open
kirillsemyonkin opened this issue Mar 1, 2025 · 3 comments

Comments

@kirillsemyonkin
Copy link
Collaborator

Add to_istring() and similar methods to applicable types, so that it is possible to use a more precise method than into(), without using path-ful calls like IString::from(Rc::from(...)).

May aid with #56, but it might also have the implementation collision akin to having both From<&'static str> and From<&'a str>. In this case it might be probable to make the two do different behaviors: .to_istring() would be always cloning/copying, and would always turn &'static str into an IString::Rc. Also consider even more precise to_istring_static and to_istring_rc (these method names might be too verbose).

Also consider .collect_iarray() and similar, akin to itertools's collect_vec.

@cecton
Copy link
Member

cecton commented Mar 3, 2025

I'm not really in favor of adding traits because it feels unnecessary but I won't oppose it. implicit-clone is in alpha and if you think this can bring value I think we should try. Worst case scenario we will remove it at the next alpha or before the first stable release.

@kirillsemyonkin
Copy link
Collaborator Author

I just had to add those extension traits in my code using ImplicitClone structures, probably because .into() was not reliable enough. Also helps users to not do str.to_string().into() (when an Rc::from(str).into() would be desired) and do str.to_istring() immediately (although that may be resolved if you make .into() work on any &str anyway)

@cecton
Copy link
Member

cecton commented Mar 3, 2025

I've never really bothered that much about performances but I understand the struggle. I did try a few times to convert an &str to an IString and everytime it feels like something that you should be able to do easily instead of being lead into a not optimal solution.

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