More documentation.

This commit is contained in:
Gav Wood
2016-02-03 13:20:32 +01:00
parent cef157e83a
commit c531150f44
17 changed files with 87 additions and 86 deletions

View File

@@ -83,11 +83,12 @@ impl<'a> fmt::Display for PrettySlice<'a> {
}
}
/// TODO [Gav Wood] Please document me
/// Trait to allow a type to be pretty-printed in `format!`, where unoverridable
/// defaults cannot otherwise be avoided.
pub trait ToPretty {
/// TODO [Gav Wood] Please document me
/// Convert a type into a derivative form in order to make `format!` print it prettily.
fn pretty(&self) -> PrettySlice;
/// TODO [Gav Wood] Please document me
/// Express the object as a hex string.
fn to_hex(&self) -> String {
format!("{}", self.pretty())
}
@@ -144,11 +145,12 @@ pub type Bytes = Vec<u8>;
/// Slice of bytes to underlying memory
pub trait BytesConvertable {
// TODO: rename to as_slice
/// TODO [Gav Wood] Please document me
/// Get the underlying byte-wise representation of the value.
/// Deprecated - use `as_slice` instead.
fn bytes(&self) -> &[u8];
/// TODO [Gav Wood] Please document me
/// Get the underlying byte-wise representation of the value.
fn as_slice(&self) -> &[u8] { self.bytes() }
/// TODO [Gav Wood] Please document me
/// Get a copy of the underlying byte-wise representation.
fn to_bytes(&self) -> Bytes { self.as_slice().to_vec() }
}

View File

@@ -48,7 +48,7 @@ macro_rules! flushln {
($fmt:expr, $($arg:tt)*) => (flush!(concat!($fmt, "\n"), $($arg)*));
}
/// TODO [Gav Wood] Please document me
#[doc(hidden)]
pub fn flush(s: String) {
::std::io::stdout().write(s.as_bytes()).unwrap();
::std::io::stdout().flush().unwrap();

View File

@@ -72,7 +72,7 @@ impl<'db> TrieDBMut<'db> {
// TODO: return Result<Self, TrieError>
pub fn from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self {
if !db.exists(root) {
flush(format!("Trie root not found {}", root));
flushln!("Trie root not found {}", root);
panic!("Trie root not found!");
}
TrieDBMut {