From d234e1c73b1f3d69382d5230eaed9c1fb025fa69 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 13 Oct 2018 03:20:42 +0000 Subject: [PATCH] Added Rust documentation comments for Version and Mask struct+impl. --- rust/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index e2f1359..ffaaeff 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1220,30 +1220,40 @@ impl BitBuffer { /*---- Miscellaneous values ----*/ +/// A number between 1 and 40 (inclusive). #[derive(Copy, Clone)] pub struct Version(u8); impl Version { + /// Creates a version object from the given number. + /// + /// Panics if the number is outside the range [1, 40]. pub fn new(ver: u8) -> Self { assert!(QrCode_MIN_VERSION.value() <= ver && ver <= QrCode_MAX_VERSION.value(), "Version number out of range"); Version(ver) } + /// Returns the value, which is in the range [1, 40]. pub fn value(&self) -> u8 { self.0 } } +/// A number between 0 and 7 (inclusive). #[derive(Copy, Clone)] pub struct Mask(u8); impl Mask { + /// Creates a mask object from the given number. + /// + /// Panics if the number is outside the range [0, 7]. pub fn new(mask: u8) -> Self { assert!(mask <= 7, "Mask value out of range"); Mask(mask) } + /// Returns the value, which is in the range [0, 7]. pub fn value(&self) -> u8 { self.0 }