mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
add annotation support
This commit is contained in:
parent
b01285d780
commit
7996a98908
6 changed files with 308 additions and 3 deletions
|
@ -69,6 +69,18 @@ impl<'a> TCString<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Consume this TCString and return an equivalent String, or an error if not
|
||||
/// valid UTF-8. In the error condition, the original data is lost.
|
||||
pub(crate) fn into_string(self) -> Result<String, std::str::Utf8Error> {
|
||||
match self {
|
||||
TCString::CString(cstring) => cstring.into_string().map_err(|e| e.utf8_error()),
|
||||
TCString::CStr(cstr) => cstr.to_str().map(|s| s.to_string()),
|
||||
TCString::String(string) => Ok(string),
|
||||
TCString::InvalidUtf8(e, _) => Err(e),
|
||||
TCString::None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
match self {
|
||||
TCString::CString(cstring) => cstring.as_bytes(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue