Add fully qualified docs

Signed-off-by: Ana Hobden <operator@hoverbear.org>
This commit is contained in:
Ana Hobden 2019-09-05 06:28:15 -07:00
parent 836f5bbc43
commit 0d6de4ba30
2 changed files with 13 additions and 21 deletions

View File

@ -34,15 +34,17 @@ use std::{fmt, u8};
/// let from_bytes = Key::from(bytes);
/// assert_eq!(from_static_str, from_bytes);
/// ```
///
/// In order to get the wrapped value you can use `to_inner`:
///
///
/// While `.into()` is usually sufficient for obtaining the buffer itself, sometimes type inference
/// isn't able to determine the correct type. Notably in the `assert_eq!()` and `==` cases. In
/// these cases using the fully-qualified-syntax is useful:
///
/// ```rust
/// use tikv_client::Key;
///
///
/// let buf = "TiKV".as_bytes().to_owned();
/// let key = Key::from(buf.clone());
/// assert_eq!(key.to_inner(), buf);
/// assert_eq!(Into::<Vec<u8>>::into(key), buf);
/// ```
///
/// Many functions which accept a `Key` accept an `Into<Key>`, which means all of the above types
@ -94,12 +96,6 @@ impl Key {
Bound::Excluded(self)
}
}
/// Unwrap the key into the byte vector contained within.
#[inline]
pub fn to_inner(self) -> Vec<u8> {
self.0
}
}
impl From<Vec<u8>> for Key {

View File

@ -34,14 +34,16 @@ use std::{fmt, str, u8};
/// assert_eq!(from_static_str, from_bytes);
/// ```
///
/// In order to get the wrapped value you can use `to_inner`:
///
/// While `.into()` is usually sufficient for obtaining the buffer itself, sometimes type inference
/// isn't able to determine the correct type. Notably in the `assert_eq!()` and `==` cases. In
/// these cases using the fully-qualified-syntax is useful:
///
/// ```rust
/// use tikv_client::Value;
///
///
/// let buf = "TiKV".as_bytes().to_owned();
/// let value = Value::from(buf.clone());
/// assert_eq!(value.to_inner(), buf);
/// assert_eq!(Into::<Vec<u8>>::into(value), buf);
/// ```
///
/// Many functions which accept a `Value` accept an `Into<Value>`, which means all of the above types
@ -63,12 +65,6 @@ impl Value {
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
/// Unwrap the value into the byte vector contained within.
#[inline]
pub fn to_inner(self) -> Vec<u8> {
self.0
}
}
impl From<Vec<u8>> for Value {