Closed k-bx closed 1 year ago
Why not store the url as a member of your struct rather than computing it on each invocation of redirect_uri?
Would I need to make the whole struct be static then? I did make a set of global &'static str
s that I query but it just seems overcomplicating the code a little.
No, the struct wouldn't need to be static.
fn redirect_uri(&self) -> Option<&str>
indicates that the &str
returned needs to live for at least as long as the &self
reference. The struct would own a String
that gets created using format!
on construction and redirect_uri
would just return &str
that's a view into that String
I see, thanks for explaining!
I'm trying to implement something like:
but I can't, because of lifetimes. I see no good reason to make it return
&str
and notString
, would be a nice change IMO.