swc_core::ecma::utils::swc_common::pass::util::move_map

Trait MoveMap

pub trait MoveMap<T>: Sized {
    // Required method
    fn move_flat_map<F, I>(self, f: F) -> Self
       where F: FnMut(T) -> I,
             I: IntoIterator<Item = T>;

    // Provided method
    fn move_map<F>(self, f: F) -> Self
       where F: FnMut(T) -> T { ... }
}
Available on crate features __ecma and __utils only.
Expand description

Modifiers vector in-place.

Required Methods§

fn move_flat_map<F, I>(self, f: F) -> Self
where F: FnMut(T) -> I, I: IntoIterator<Item = T>,

This will be very slow if you try to extend vector using this method.

This method exists to drop useless nodes. You can return Option to do such shortening.

Provided Methods§

fn move_map<F>(self, f: F) -> Self
where F: FnMut(T) -> T,

Map in place.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<T> MoveMap<T> for Vec<T>

§

fn move_map<F>(self, f: F) -> Vec<T>
where F: FnMut(T) -> T,

This reduces binary size.

§

fn move_flat_map<F, I>(self, f: F) -> Vec<T>
where F: FnMut(T) -> I, I: IntoIterator<Item = T>,

Implementors§