Skip to content

Commit 8f633cc

Browse files
TAdev0enitrat
andauthored
Core Lib Documentation: One module (#6780)
Co-authored-by: enitrat <[email protected]>
1 parent 4ae8415 commit 8f633cc

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

corelib/src/num/traits/one.cairo

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1+
//! Traits for types with a multiplicative identity element.
2+
13
/// Defines a multiplicative identity element for `T`.
4+
///
5+
/// # Laws
6+
///
7+
/// ```text
8+
/// a * 1 = a ∀ a ∈ T
9+
/// 1 * a = a ∀ a ∈ T
10+
/// ```
211
pub trait One<T> {
312
/// Returns the multiplicative identity element of `T`, `1`.
13+
///
14+
/// # Examples
15+
///
16+
/// ```
17+
/// use core::num::traits::One;
18+
///
19+
/// assert!(One::<u32>::one() == 1);
20+
/// ```
421
fn one() -> T;
5-
/// Returns `true` if `self` is equal to the multiplicative identity.
22+
23+
/// Returns true if `self` is equal to the multiplicative identity.
24+
///
25+
/// # Examples
26+
///
27+
/// ```
28+
/// use core::num::traits::One;
29+
///
30+
/// assert!(1.is_one());
31+
/// assert!(!0.is_one());
32+
/// ```
633
fn is_one(self: @T) -> bool;
7-
/// Returns `false` if `self` is equal to the multiplicative identity.
34+
35+
/// Returns false if `self` is equal to the multiplicative identity.
36+
///
37+
/// # Examples
38+
///
39+
/// ```
40+
/// use core::num::traits::One;
41+
///
42+
/// assert!(0.is_non_one());
43+
/// assert!(!1.is_non_one());
44+
/// ```
845
fn is_non_one(self: @T) -> bool;
946
}

0 commit comments

Comments
 (0)