File tree Expand file tree Collapse file tree 1 file changed +39
-2
lines changed
Expand file tree Collapse file tree 1 file changed +39
-2
lines changed Original file line number Diff line number Diff line change 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+ /// ```
211pub 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}
You can’t perform that action at this time.
0 commit comments