pub struct ConcatSource { /* private fields */ }
Expand description
Concatenate multiple Sources to a single Source.
use rspack_sources::{
BoxSource, ConcatSource, MapOptions, OriginalSource, RawSource, Source,
SourceExt, SourceMap,
};
let mut source = ConcatSource::new([
RawSource::from("Hello World\n".to_string()).boxed(),
OriginalSource::new(
"console.log('test');\nconsole.log('test2');\n",
"console.js",
)
.boxed(),
]);
source.add(OriginalSource::new("Hello2\n", "hello.md"));
assert_eq!(source.size(), 62);
assert_eq!(
source.source(),
"Hello World\nconsole.log('test');\nconsole.log('test2');\nHello2\n"
);
assert_eq!(
source.map(&MapOptions::new(false)).unwrap(),
SourceMap::from_json(
r#"{
"version": 3,
"mappings": ";AAAA;AACA;ACDA",
"names": [],
"sources": ["console.js", "hello.md"],
"sourcesContent": [
"console.log('test');\nconsole.log('test2');\n",
"Hello2\n"
]
}"#,
)
.unwrap()
);
Implementations§
Source§impl ConcatSource
impl ConcatSource
Sourcepub fn new<S, T>(sources: S) -> Selfwhere
T: Source + 'static,
S: IntoIterator<Item = T>,
pub fn new<S, T>(sources: S) -> Selfwhere
T: Source + 'static,
S: IntoIterator<Item = T>,
Create a ConcatSource with Sources.
Trait Implementations§
Source§impl Clone for ConcatSource
impl Clone for ConcatSource
Source§fn clone(&self) -> ConcatSource
fn clone(&self) -> ConcatSource
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ConcatSource
impl Debug for ConcatSource
Source§impl Default for ConcatSource
impl Default for ConcatSource
Source§fn default() -> ConcatSource
fn default() -> ConcatSource
Returns the “default value” for a type. Read more
Source§impl Hash for ConcatSource
impl Hash for ConcatSource
Source§impl PartialEq for ConcatSource
impl PartialEq for ConcatSource
Source§impl Source for ConcatSource
impl Source for ConcatSource
Source§impl StreamChunks for ConcatSource
impl StreamChunks for ConcatSource
Source§fn stream_chunks<'a>(
&'a self,
options: &MapOptions,
on_chunk: OnChunk<'_, 'a>,
on_source: OnSource<'_, 'a>,
on_name: OnName<'_, 'a>,
) -> GeneratedInfo
fn stream_chunks<'a>( &'a self, options: &MapOptions, on_chunk: OnChunk<'_, 'a>, on_source: OnSource<'_, 'a>, on_name: OnName<'_, 'a>, ) -> GeneratedInfo
StreamChunks abstraction
impl Eq for ConcatSource
Auto Trait Implementations§
impl Freeze for ConcatSource
impl !RefUnwindSafe for ConcatSource
impl Send for ConcatSource
impl Sync for ConcatSource
impl Unpin for ConcatSource
impl !UnwindSafe for ConcatSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more