Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vortex-session/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ pub fn vortex_session::VortexSession::empty() -> Self

pub fn vortex_session::VortexSession::with<V: vortex_session::SessionVar + core::default::Default>(self) -> Self

pub fn vortex_session::VortexSession::with_some<V: vortex_session::SessionVar>(self, var: V) -> Self

impl core::clone::Clone for vortex_session::VortexSession

pub fn vortex_session::VortexSession::clone(&self) -> vortex_session::VortexSession
Expand Down
11 changes: 10 additions & 1 deletion vortex-session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ impl VortexSession {
///
/// If a variable of that type already exists.
pub fn with<V: SessionVar + Default>(self) -> Self {
self.with_some(V::default())
}

/// Inserts a new session variable of type `V`.
///
/// # Panics
///
/// If a variable of that type already exists.
pub fn with_some<V: SessionVar>(self, var: V) -> Self {
match self.0.entry(TypeId::of::<V>()) {
Entry::Occupied(_) => {
vortex_panic!(
Expand All @@ -47,7 +56,7 @@ impl VortexSession {
);
}
Entry::Vacant(e) => {
e.insert(Box::new(V::default()));
e.insert(Box::new(var));
}
}
self
Expand Down
Loading