Skip to content

Commit

Permalink
feat: allow taking ValueRefMut as session input
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Apr 13, 2024
1 parent 681da43 commit 63a1818
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/session/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ use std::{borrow::Cow, collections::HashMap, ops::Deref};

use crate::{
value::{DynValueTypeMarker, ValueTypeMarker},
Value, ValueRef
Value, ValueRef, ValueRefMut
};

pub enum SessionInputValue<'v> {
ViewMut(ValueRefMut<'v, DynValueTypeMarker>),
View(ValueRef<'v, DynValueTypeMarker>),
Owned(Value<DynValueTypeMarker>)
}
Expand All @@ -15,12 +16,18 @@ impl<'v> Deref for SessionInputValue<'v> {

fn deref(&self) -> &Self::Target {
match self {
SessionInputValue::ViewMut(v) => v,
SessionInputValue::View(v) => v,
SessionInputValue::Owned(v) => v
}
}
}

impl<'v, T: ValueTypeMarker + ?Sized> From<ValueRefMut<'v, T>> for SessionInputValue<'v> {
fn from(value: ValueRefMut<'v, T>) -> Self {
SessionInputValue::ViewMut(value.into_dyn())
}
}
impl<'v, T: ValueTypeMarker + ?Sized> From<ValueRef<'v, T>> for SessionInputValue<'v> {
fn from(value: ValueRef<'v, T>) -> Self {
SessionInputValue::View(value.into_dyn())
Expand Down

0 comments on commit 63a1818

Please sign in to comment.