Replace use of unstable Option::flatten() with and_then()

This commit is contained in:
Dirkjan Ochtman
2019-08-26 21:26:10 +02:00
parent ca11dc2031
commit ce0113eb19
5 changed files with 4 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ fn save(
// If there is no filename, check the metadata for the origin filename
if input.len() > 0 {
let origin = input[0].origin();
match origin.map(|x| source_map.get(&x)).flatten() {
match origin.and_then(|x| source_map.get(&x)) {
Some(path) => match path {
SpanSource::File(file) => {
full_path.push(Path::new(file));

View File

@@ -38,7 +38,7 @@ fn tags(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream,
dict.insert("end", Value::int(span.end as i64));
tags.insert_tagged("span", dict.into_tagged_value());
match origin.map(|x| source_map.get(&x)).flatten() {
match origin.and_then(|x| source_map.get(&x)) {
Some(SpanSource::File(source)) => {
tags.insert("origin", Value::string(source));
}