pub struct CachedSource<T> { /* private fields */ }Expand description
It tries to reused cached results from other methods to avoid calculations, usually used after modify is finished.
use rustbolt_sources::{
BoxSource, CachedSource, ConcatSource, MapOptions, OriginalSource,
RawSource, Source, SourceExt, SourceMap,
};
let mut concat = ConcatSource::new([
RawSource::from("Hello World\n".to_string()).boxed(),
OriginalSource::new(
"console.log('test');\nconsole.log('test2');\n",
"console.js",
)
.boxed(),
]);
concat.add(OriginalSource::new("Hello2\n", "hello.md"));
let cached = CachedSource::new(concat);
assert_eq!(
cached.source(),
"Hello World\nconsole.log('test');\nconsole.log('test2');\nHello2\n"
);
// second time will be fast.
assert_eq!(
cached.source(),
"Hello World\nconsole.log('test');\nconsole.log('test2');\nHello2\n"
);Implementations§
Trait Implementations§
Source§impl<T> Clone for CachedSource<T>
impl<T> Clone for CachedSource<T>
Source§impl<T: Debug> Debug for CachedSource<T>
impl<T: Debug> Debug for CachedSource<T>
Source§impl<T: PartialEq> PartialEq for CachedSource<T>
impl<T: PartialEq> PartialEq for CachedSource<T>
Source§impl<T: Source + Hash + PartialEq + Eq + 'static> Source for CachedSource<T>
impl<T: Source + Hash + PartialEq + Eq + 'static> Source for CachedSource<T>
Source§impl<T: Source + Hash + PartialEq + Eq + 'static> StreamChunks for CachedSource<T>
impl<T: Source + Hash + PartialEq + Eq + 'static> StreamChunks for CachedSource<T>
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<T: Eq> Eq for CachedSource<T>
Auto Trait Implementations§
impl<T> Freeze for CachedSource<T>
impl<T> !RefUnwindSafe for CachedSource<T>
impl<T> Send for CachedSource<T>
impl<T> Sync for CachedSource<T>
impl<T> Unpin for CachedSource<T>
impl<T> !UnwindSafe for CachedSource<T>
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