Struct rspack_sources::OriginalSource
source · pub struct OriginalSource { /* private fields */ }
Expand description
Represents source code, it will create source map for the source code,
but the source map is created by splitting the source code at typical
statement borders (;
, {
, }
).
use rspack_sources::{OriginalSource, MapOptions, Source};
let input = "if (hello()) { world(); hi(); there(); } done();\nif (hello()) { world(); hi(); there(); } done();";
let source = OriginalSource::new(input, "file.js");
assert_eq!(source.source(), input);
assert_eq!(
source.map(&MapOptions::default()).unwrap().mappings(),
"AAAA,eAAe,SAAS,MAAM,WAAW;AACzC,eAAe,SAAS,MAAM,WAAW",
);
assert_eq!(
source.map(&MapOptions::new(false)).unwrap().mappings(),
"AAAA;AACA",
);
Implementations§
Trait Implementations§
source§impl Clone for OriginalSource
impl Clone for OriginalSource
source§fn clone(&self) -> OriginalSource
fn clone(&self) -> OriginalSource
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 OriginalSource
impl Debug for OriginalSource
source§impl Hash for OriginalSource
impl Hash for OriginalSource
source§impl PartialEq for OriginalSource
impl PartialEq for OriginalSource
source§impl Source for OriginalSource
impl Source for OriginalSource
source§impl StreamChunks for OriginalSource
impl StreamChunks for OriginalSource
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 OriginalSource
Auto Trait Implementations§
impl Freeze for OriginalSource
impl RefUnwindSafe for OriginalSource
impl Send for OriginalSource
impl Sync for OriginalSource
impl Unpin for OriginalSource
impl UnwindSafe for OriginalSource
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