better doc

This commit is contained in:
Edward Shen 2021-02-27 19:01:01 -05:00
parent 99f0400118
commit 60f95a0358
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -1,6 +1,5 @@
//! Rust containers for valid `git-config` types. //! Rust containers for valid `git-config` types.
use crate::parser::Event;
use bstr::{BStr, ByteSlice}; use bstr::{BStr, ByteSlice};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
@ -43,7 +42,7 @@ use std::str::FromStr;
/// assert_eq!(normalize(b"hello \"world\""), Cow::<[u8]>::Owned(b"hello world".to_vec())); /// assert_eq!(normalize(b"hello \"world\""), Cow::<[u8]>::Owned(b"hello world".to_vec()));
/// ``` /// ```
/// ///
/// Escaped quotes are ignored. /// Escaped quotes are unescaped.
/// ///
/// ``` /// ```
/// # use std::borrow::Cow; /// # use std::borrow::Cow;
@ -131,32 +130,6 @@ pub enum ValueEventConversionError {
NoValue, NoValue,
} }
// impl<'a, 'b> TryFrom<&'b [Event<'a>]> for Value<'a> {
// type Error = ValueEventConversionError;
// fn try_from(events: &'b [Event<'a>]) -> Result<Self, Self::Error> {
// let mut v = vec![];
// for event in events {
// match event {
// Event::Value(v) => return Ok(Self::from(v.borrow())),
// Event::ValueNotDone(value) => v.extend(value.borrow()),
// Event::ValueDone(value) => {
// v.extend(value.borrow());
// // return Ok(Self::from(v));
// }
// _ => (),
// }
// }
// if v.is_empty() {
// Err(Self::Error::NoValue)
// } else {
// Err(Self::Error::ValueNotDone)
// }
// }
// }
impl<'a> From<&'a str> for Value<'a> { impl<'a> From<&'a str> for Value<'a> {
fn from(s: &'a str) -> Self { fn from(s: &'a str) -> Self {
if let Ok(bool) = Boolean::try_from(s) { if let Ok(bool) = Boolean::try_from(s) {