Merge pull request #468 from djc/unflattening

Replace use of unstable Option::flatten() with and_then()
This commit is contained in:
Jonathan Turner 2019-08-27 09:27:27 +12:00 committed by GitHub
commit 69492a10fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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));
}

View File

@ -3,7 +3,6 @@
#![feature(generators)]
#![feature(try_trait)]
#![feature(bind_by_move_pattern_guards)]
#![feature(option_flattening)]
#![feature(specialization)]
#![feature(proc_macro_hygiene)]

View File

@ -1,4 +1,3 @@
#![feature(option_flattening)]
use crossterm::{cursor, terminal, Attribute, RawScreen};
use indexmap::IndexMap;
use nu::{
@ -32,7 +31,7 @@ impl Plugin for BinaryView {
let value_origin = v.origin();
match v.item {
Value::Binary(b) => {
let source = value_origin.map(|x| call_info.source_map.get(&x)).flatten();
let source = value_origin.and_then(|x| call_info.source_map.get(&x));
let _ = view_binary(&b, source, call_info.args.has("lores"));
}
_ => {}

View File

@ -1,5 +1,3 @@
#![feature(option_flattening)]
use crossterm::{cursor, terminal, RawScreen};
use crossterm::{InputEvent, KeyEvent};
use indexmap::IndexMap;
@ -217,7 +215,7 @@ fn view_text_value(value: &Tagged<Value>, source_map: &SourceMap) {
let value_origin = value.origin();
match value.item {
Value::Primitive(Primitive::String(ref s)) => {
let source = value_origin.map(|x| source_map.get(&x)).flatten();
let source = value_origin.and_then(|x| source_map.get(&x));
if let Some(source) = source {
let extension: Option<String> = match source {