From fd425bf995f08ec716efbbe0c86c432e39022c4c Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Wed, 28 Jul 2021 19:53:05 +0000 Subject: [PATCH] Publicized the Rust functions QrSegment.{is_numeric(),is_alphanumeric()}. --- rust/src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index d35d819..ebb972c 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1116,17 +1116,19 @@ impl QrSegment { } - // Tests whether the given string can be encoded as a segment in numeric mode. - // A string is encodable iff each character is in the range 0 to 9. - fn is_numeric(text: &[char]) -> bool { + /// Tests whether the given string can be encoded as a segment in numeric mode. + /// + /// A string is encodable iff each character is in the range 0 to 9. + pub fn is_numeric(text: &[char]) -> bool { text.iter().all(|&c| '0' <= c && c <= '9') } - // Tests whether the given string can be encoded as a segment in alphanumeric mode. - // A string is encodable iff each character is in the following set: 0 to 9, A to Z - // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. - fn is_alphanumeric(text: &[char]) -> bool { + /// Tests whether the given string can be encoded as a segment in alphanumeric mode. + /// + /// A string is encodable iff each character is in the following set: 0 to 9, A to Z + /// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. + pub fn is_alphanumeric(text: &[char]) -> bool { text.iter().all(|c| ALPHANUMERIC_CHARSET.contains(c)) }