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

impl Valuable for Path and PathBuf #25

Merged
merged 3 commits into from
May 14, 2021
Merged

impl Valuable for Path and PathBuf #25

merged 3 commits into from
May 14, 2021

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented May 14, 2021

No description provided.

Comment on lines 211 to 229
struct Error;
static ERROR: Error = Error;
const MSG: &str = "path is not valid UTF-8 string";
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&MSG, f)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&MSG, f)
}
}
impl std::error::Error for Error {}

match self.to_str() {
Some(s) => Value::String(s),
None => Value::Error(&ERROR),
}
Copy link
Member Author

@taiki-e taiki-e May 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is really preferable. Ideally, I would like to call Path::display, but that would be difficult.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider adding Path as a primitive. What do you think?

Ref: #4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth having path be a primitive...i can imagine user code wanting to inspect them as paths. OTTOH, this would need to be feature flagged for when the standard library is not in use (since tracing supports no-std + alloc)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to make sense. Added Value::Path.

@taiki-e taiki-e merged commit ed75ed9 into master May 14, 2021
@taiki-e taiki-e deleted the taiki-e/path branch May 14, 2021 19:21
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.

3 participants