Skip to content

Conversation

@eliad-wiz
Copy link

implement valuable for Path instead of &Path, in order to support types like Box

implement valuable for Path instead of &Path, in order to support
types like Box<Path>

Signed-off-by: Eliad Peller <[email protected]>
@taiki-e
Copy link
Member

taiki-e commented Apr 4, 2023

Thanks for the PR. IIRC, I implemented Valuable for the reference to match the Valuable implementation of str.

@eliad-wiz
Copy link
Author

the &str impl uses some specific optimization for slices:

impl Valuable for &'_ str {
    fn as_value(&self) -> Value<'_> {
        Value::String(self)
    }

    fn visit(&self, visit: &mut dyn Visit) {
        visit.visit_value(Value::String(self));
    }

    fn visit_slice(slice: &[Self], visit: &mut dyn Visit)
    where
        Self: Sized,
    {
        visit.visit_primitive_slice(Slice::Str(slice));
    }
}

Path is not a primitive type, so i guess it's different.
(btw, currently the implementation for Box in indeed missing. i guess it should either be added explicitly or the &str impl should be changed to str as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants