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 rustbolt_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 duplicate 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<'a>(
&'a self,
options: &MapOptions,
on_chunk: OnChunk<'_, 'a>,
on_source: OnSource<'_, 'a>,
_on_name: OnName<'_, '_>,
) -> GeneratedInfo
fn stream_chunks<'a>( &'a self, options: &MapOptions, on_chunk: OnChunk<'_, 'a>, on_source: OnSource<'_, 'a>, _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
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