Implement conversion from IceResult into BreadcrumbTreeNode.
I believe this change will remove an extra heap allocation I was doing in the new_breadcrumbs_* functions for the explicit context by adding support for converting from Rc<dyn ContextElement> to Rc<dyn IntoContextElement> without copying the underlying data. This should allow conversion of the IceResult::Owned variant to the BreadcrumbTreeElement::Owned variant without extra copying.
This commit is contained in:
@@ -16,6 +16,7 @@ pub trait ContextElement:
|
||||
// + CloneIntoBoxedContextElement
|
||||
+ CompareContextElement
|
||||
+ FromContextElement
|
||||
+ IntoRcIce
|
||||
{
|
||||
}
|
||||
|
||||
@@ -119,6 +120,16 @@ impl<C: ContextElement> IntoContextElement for C {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IntoRcIce {
|
||||
fn into_rc_ice(self: Rc<Self>) -> Rc<dyn IntoContextElement>;
|
||||
}
|
||||
|
||||
impl<C: 'static + ContextElement> IntoRcIce for C {
|
||||
fn into_rc_ice(self: Rc<C>) -> Rc<dyn IntoContextElement> {
|
||||
Rc::clone(&self) as Rc<dyn IntoContextElement>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum IceResult<'a> {
|
||||
// Using Rc so that when we need to create BreadcrumbTrees with
|
||||
|
||||
Reference in New Issue
Block a user