openidconnect-rs icon indicating copy to clipboard operation
openidconnect-rs copied to clipboard

Use `Into<String>` or `ToString::to_string` rather than requiring owned `Strings` up front.

Open gibbz00 opened this issue 1 year ago • 2 comments

Partly a question if there's any reason why the API requires owned strings for constructors and such.

.add_scope(Scope::new("read".to_string()))
.add_scope(Scope::new("write".to_string()))

Could then become:

.add_scope(Scope::new("read"))
.add_scope(Scope::new("write"))

And the method signature would still make it clear that an allocation will take place.

This also applies to the oath2 crate.

gibbz00 avatar May 09 '24 09:05 gibbz00

See ramosbugs/oauth2-rs#248. I'd be open to the constructor methods accepting impl Into<String> in both crates for better ergonomics.

ramosbugs avatar May 09 '24 18:05 ramosbugs

Cool cool :) Might take a look at it when I have the time.

gibbz00 avatar May 11 '24 06:05 gibbz00