The latter change introduces an unnecessary clone(). The correct approach is to instead introduce a variable so that headerRegex can keep being a reference to either that variable or to HEADER_REGEX.
Can you expand on how this stops a clone from happening?
If you don't call clone() then a clone doesn't happen...
Ah, I didn't see the extra clone. I thought it was something to do with that additional variable you defined. I guess you need to do that or else you have to do a clone.
Re:Rust is for Professionals
by shepmaster on Tuesday April 13, 2021 @02:15PM
(#26796651)
> into an `Option<&str>` from an `Option<String>`
`Option::deref` is a good choice here.
Edit 2: to further drive the point home that this should be a bug, this is the current output for a similar case while I was trying to minimize this:
https://play.rust-lang.org/?version=stable&mode=debug&editio...