Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement valuable for Path #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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