Is there someway to convert a String (function parameter) into &str (used in return value) while avoiding borrowing problems or referencing a temporary value.
Here is an example use case:
PS: I am constrained by existing functions to these types and cannot just change the type of the function's parameter nor its &str consuming return value. Also the following example uses clap::Arg::new to emphasize this aspect.
// f is any iterator over String values, for example sake I am using Vec<String> with literal value which does not represent the real case.
let f: Vec<String> = vec!["A".into(),"B".into(),"C".into()].into_iter();
let arg: clap::Arg = f.map(|s: String|{
clap::Arg::new(s.as_str())
});