Skip to content

Commit bf244ff

Browse files
committed
update description
1 parent 450e915 commit bf244ff

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

src/rule/number/equal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
macro_rules! equal_rule {
33
(($e: literal, $t: ty)) => {
44
paste::item! {
5+
/// `Equal[N][TYPE]` is a type that indicates that the number is equal to `N`.
56
#[allow(dead_code)]
67
pub type [<Equal $e $t>] = $crate::Refined<[<EqualRule $e $t>]>;
78

src/rule/number/even.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
macro_rules! even_rule {
22
($t: ty) => {
33
paste::item! {
4+
/// `Even[TYPE]` is a type that represents that the number is even.
45
#[allow(dead_code)]
56
pub type [<Even $t:upper>] = $crate::Refined<[<EvenRule $t:upper>]>;
67

src/rule/number/greater.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
macro_rules! greater_rule {
33
(($e: literal, $t: ty)) => {
44
paste::item! {
5+
/// `Greater[N][TYPE]` is a type that indicates that the number is greater than `N`.
56
#[allow(dead_code)]
67
pub type [<Greater $e $t>] = $crate::Refined<[<GreaterRule $e $t>]>;
78

src/rule/number/less.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
macro_rules! less_rule {
33
(($e: literal, $t: ty)) => {
44
paste::item! {
5+
/// `Less[N][TYPE]` is a type that indicates that the number is less than `N`.
56
#[allow(dead_code)]
67
pub type [<Less $e $t>] = $crate::Refined<[<LessRule $e $t>]>;
78

src/rule/number/odd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
macro_rules! odd_rule {
22
($t: ty) => {
33
paste::item! {
4+
/// `Odd[TYPE]` is a type that represents that the number is odd.
45
pub type [<Odd $t:upper>] = $crate::Refined<[<OddRule $t:upper>]>;
56
pub struct [<OddRule $t:upper>];
67

src/rule/string/alphabet.rs

+35
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ use crate::rule::Rule;
33
use crate::Refined;
44
use regex::Regex;
55

6+
/// The `Alphabet` type represents a type that can contain zero or more alphabetic characters.
7+
///
8+
/// # Example
9+
/// ```rust
10+
/// # use refined_type::rule::Alphabet;
11+
///
12+
/// let alphabet_result = Alphabet::new("alphabet".to_string());
13+
/// assert!(alphabet_result.is_ok());
14+
///
15+
/// let alphabet_result = Alphabet::new("I am the 1st".to_string());
16+
/// assert!(alphabet_result.is_err());
17+
/// ```
618
pub type Alphabet = Refined<AlphabetRule>;
719

820
/// A string consisting entirely of alphabetic characters
@@ -26,3 +38,26 @@ impl Rule for AlphabetRule {
2638
}
2739
}
2840
}
41+
42+
#[cfg(test)]
43+
mod test {
44+
use crate::rule::Alphabet;
45+
46+
#[test]
47+
fn test_alphabet_ok_empty() {
48+
let alphabet_result = Alphabet::new("".to_string());
49+
assert!(alphabet_result.is_ok());
50+
}
51+
52+
#[test]
53+
fn test_alphabet_ok_non_empty() {
54+
let alphabet_result = Alphabet::new("alphabet".to_string());
55+
assert!(alphabet_result.is_ok());
56+
}
57+
58+
#[test]
59+
fn test_alphabet_err() {
60+
let alphabet_result = Alphabet::new("I am the 1st".to_string());
61+
assert!(alphabet_result.is_err());
62+
}
63+
}

0 commit comments

Comments
 (0)