getset icon indicating copy to clipboard operation
getset copied to clipboard

How to have getters return `&str` from `String`?

Open poperigby opened this issue 5 months ago • 3 comments

Is this currently possible? I'd like to do this as it's more idiomatic.

poperigby avatar Aug 04 '25 02:08 poperigby

@poperigby This seems to be a similar ask to #120. #120 seemed to kind of stall out because it's very hard to handle a case where you have a type alias. Because it's not trait based, it becomes very hard to handle all cases. This ask however, while it is not currently implemented, is trait based, so there's more we can do to address it. I'm happy to work on this or a review a contribution if you want it sooner rather than later.

jbaublitz avatar Aug 04 '25 15:08 jbaublitz

Thank you 🙂. &Path over &PathBuf would also be great, as well as &[T] over &Vec<T>, if it's not too much trouble.

poperigby avatar Aug 06 '25 02:08 poperigby

I can do any conversion that is based on the AsRef trait.

jbaublitz avatar Aug 10 '25 15:08 jbaublitz