pub struct SessionGlobals { /* private fields */ }
Expand description
Per-session global variables.
This struct is stored in thread-local storage in such a way that it is accessible without any kind of handle to all threads within the compilation session, but is not accessible outside the session.
Implementations§
Source§impl SessionGlobals
impl SessionGlobals
Sourcepub fn set<R>(&self, f: impl FnOnce() -> R) -> R
pub fn set<R>(&self, f: impl FnOnce() -> R) -> R
Sets this instance as the global instance for the duration of the closure.
Sourcepub fn with_source_map<R>(
source_map: Arc<SourceMap>,
f: impl FnOnce() -> R,
) -> R
pub fn with_source_map<R>( source_map: Arc<SourceMap>, f: impl FnOnce() -> R, ) -> R
Insert source_map
into the session globals for the duration of the closure’s execution.
Sourcepub fn with<R>(f: impl FnOnce(&Self) -> R) -> R
pub fn with<R>(f: impl FnOnce(&Self) -> R) -> R
Calls the given closure with the current session globals.
§Panics
Panics if set
has not previously been called.
Sourcepub fn with_or_default<R>(f: impl FnOnce(&Self) -> R) -> R
pub fn with_or_default<R>(f: impl FnOnce(&Self) -> R) -> R
Calls the given closure with the current session globals if they have been set, otherwise creates a new instance, sets it, and calls the closure with it.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SessionGlobals
impl !RefUnwindSafe for SessionGlobals
impl Send for SessionGlobals
impl Sync for SessionGlobals
impl Unpin for SessionGlobals
impl !UnwindSafe for SessionGlobals
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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