forked from extern/nushell
Merge pull request #468 from djc/unflattening
Replace use of unstable Option::flatten() with and_then()
This commit is contained in:
commit
69492a10fe
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#![feature(generators)]
|
||||
#![feature(try_trait)]
|
||||
#![feature(bind_by_move_pattern_guards)]
|
||||
#![feature(option_flattening)]
|
||||
#![feature(specialization)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
_ => {}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user