The following code doesn’t work because the .map() closure returns a temporary value:
let card_store = match card_store_path
.extension()
.map(|oss| oss.to_string_lossy().to_lowercase().as_str())
{
Some("md") => read_card_store_from_md_file(card_store_path)?,
_ => read_card_store_from_tsv(card_store_path)?,
};
However, I can’t seem to match against String values in patterns – which would allow me to remove .as_str(). Is there a way to do this? I’d like to avoid unwrapping the option via if let.