Rollup merge of #108887 - nnethercote:rename-MapInPlace, r=lqd
Rename `MapInPlace` as `FlatMapInPlace`. After removing the `map_in_place` method, which isn't much use because modifying every element in a collection such as a `Vec` can be done trivially with iteration. r? ``@lqd``
This commit is contained in:
commit
a95943b77d
@ -12,7 +12,7 @@ use crate::ptr::P;
|
|||||||
use crate::token::{self, Token};
|
use crate::token::{self, Token};
|
||||||
use crate::tokenstream::*;
|
use crate::tokenstream::*;
|
||||||
|
|
||||||
use rustc_data_structures::map_in_place::MapInPlace;
|
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
|
@ -2,14 +2,7 @@ use smallvec::{Array, SmallVec};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
|
||||||
pub trait MapInPlace<T>: Sized {
|
pub trait FlatMapInPlace<T>: Sized {
|
||||||
fn map_in_place<F>(&mut self, mut f: F)
|
|
||||||
where
|
|
||||||
F: FnMut(T) -> T,
|
|
||||||
{
|
|
||||||
self.flat_map_in_place(|e| Some(f(e)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn flat_map_in_place<F, I>(&mut self, f: F)
|
fn flat_map_in_place<F, I>(&mut self, f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(T) -> I,
|
F: FnMut(T) -> I,
|
||||||
@ -66,14 +59,14 @@ macro_rules! flat_map_in_place {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> MapInPlace<T> for Vec<T> {
|
impl<T> FlatMapInPlace<T> for Vec<T> {
|
||||||
flat_map_in_place!();
|
flat_map_in_place!();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, A: Array<Item = T>> MapInPlace<T> for SmallVec<A> {
|
impl<T, A: Array<Item = T>> FlatMapInPlace<T> for SmallVec<A> {
|
||||||
flat_map_in_place!();
|
flat_map_in_place!();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> MapInPlace<T> for ThinVec<T> {
|
impl<T> FlatMapInPlace<T> for ThinVec<T> {
|
||||||
flat_map_in_place!();
|
flat_map_in_place!();
|
||||||
}
|
}
|
@ -50,6 +50,7 @@ pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
|
|||||||
pub mod base_n;
|
pub mod base_n;
|
||||||
pub mod binary_search_util;
|
pub mod binary_search_util;
|
||||||
pub mod captures;
|
pub mod captures;
|
||||||
|
pub mod flat_map_in_place;
|
||||||
pub mod flock;
|
pub mod flock;
|
||||||
pub mod functor;
|
pub mod functor;
|
||||||
pub mod fx;
|
pub mod fx;
|
||||||
@ -57,7 +58,6 @@ pub mod graph;
|
|||||||
pub mod intern;
|
pub mod intern;
|
||||||
pub mod jobserver;
|
pub mod jobserver;
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
pub mod map_in_place;
|
|
||||||
pub mod obligation_forest;
|
pub mod obligation_forest;
|
||||||
pub mod owning_ref;
|
pub mod owning_ref;
|
||||||
pub mod sip128;
|
pub mod sip128;
|
||||||
|
@ -12,8 +12,8 @@ use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
|
|||||||
use rustc_ast::NodeId;
|
use rustc_ast::NodeId;
|
||||||
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
|
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
|
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::map_in_place::MapInPlace;
|
|
||||||
use rustc_feature::{Feature, Features, State as FeatureState};
|
use rustc_feature::{Feature, Features, State as FeatureState};
|
||||||
use rustc_feature::{
|
use rustc_feature::{
|
||||||
ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES,
|
ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES,
|
||||||
|
@ -20,7 +20,7 @@ use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId};
|
|||||||
use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
|
use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
|
||||||
use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
|
use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::map_in_place::MapInPlace;
|
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::PResult;
|
use rustc_errors::PResult;
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user