-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
valuable/src/valuable.rs
Outdated
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), | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
.
No description provided.