Additional doc/tests.

This commit is contained in:
Gav Wood 2015-12-20 12:22:54 +00:00
parent 435911b9f0
commit c718a5c627

View File

@ -63,7 +63,16 @@ pub struct Params {
}
// TODO: move to ethcore-util
/// A version value with strict meaning.
/// A version value with strict meaning. Use `to_u32` to convert to a simple integer.
///
/// # Example
/// ```
/// extern crate ethcore;
/// use ethcore::engine::*;
/// fn main() {
/// assert_eq!(SemanticVersion::new(1, 2, 3).as_u32(), 0x010203);
/// }
/// ```
pub struct SemanticVersion {
/// Major version - API/feature removals & breaking changes.
pub major: u8,
@ -78,7 +87,7 @@ impl SemanticVersion {
pub fn new(major: u8, minor: u8, tiny: u8) -> SemanticVersion { SemanticVersion{major: major, minor: minor, tiny: tiny} }
/// Convert to a `u32` representation.
pub fn as_u32(&self) -> u32 { ((self.major as u32) << 16u32) + ((self.minor as u32) << 8u32) + self.tiny as u32 }
pub fn as_u32(&self) -> u32 { ((self.major as u32) << 16) + ((self.minor as u32) << 8) + self.tiny as u32 }
}
// TODO: implement PartialOrdered for SemanticVersion.