Struct rspack_sources::ConcatSource
source · 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(
&self,
options: &MapOptions,
on_chunk: OnChunk<'_>,
on_source: OnSource<'_>,
on_name: OnName<'_>,
) -> GeneratedInfo
fn stream_chunks( &self, options: &MapOptions, on_chunk: OnChunk<'_>, on_source: OnSource<'_>, on_name: OnName<'_>, ) -> 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