diff --git a/src/ctx/context.rs b/src/ctx/context.rs index 8e14c200..d4d9d3a6 100644 --- a/src/ctx/context.rs +++ b/src/ctx/context.rs @@ -17,7 +17,13 @@ pub struct Context { // Wether or not this context is cancelled. cancelled: Arc, // A collection of read only values stored in this context. - values: Option>>, + values: Option>>, +} + +impl Default for Context { + fn default() -> Self { + Context::background() + } } impl Context { @@ -74,7 +80,7 @@ impl Context { // Add a value to the context. It overwrites any previously set values // with the same key. - pub fn add_value(&mut self, key: &'static str, value: V) + pub fn add_value(&mut self, key: String, value: V) where V: Any + Send + Sync + Sized, { @@ -148,7 +154,7 @@ impl Context { // Get a value from the context. If no value is stored under the // provided key, then this will return None. - pub fn value(&self, key: &'static str) -> Option<&V> + pub fn value(&self, key: String) -> Option<&V> where V: Any + Send + Sync + Sized, {