@@ -889,7 +889,7 @@ pub struct PluralElements<'a, T: ?Sized> {
889
889
explicit_one : Option < & ' a T > ,
890
890
}
891
891
892
- impl < ' a , T : ?Sized + PartialEq > PluralElements < ' a , T > {
892
+ impl < ' a , T : ?Sized > PluralElements < ' a , T > {
893
893
/// Creates a new [`PluralElements`] with the given default value.
894
894
pub fn new ( other : & ' a T ) -> Self {
895
895
Self {
@@ -904,6 +904,58 @@ impl<'a, T: ?Sized + PartialEq> PluralElements<'a, T> {
904
904
}
905
905
}
906
906
907
+ /// The value for [`PluralCategory::Zero`]
908
+ pub fn zero ( & self ) -> & ' a T {
909
+ self . zero . unwrap_or ( self . other )
910
+ }
911
+
912
+ /// The value for [`PluralCategory::One`]
913
+ pub fn one ( & self ) -> & ' a T {
914
+ self . one . unwrap_or ( self . other )
915
+ }
916
+
917
+ /// The value for [`PluralCategory::Two`]
918
+ pub fn two ( & self ) -> & ' a T {
919
+ self . two . unwrap_or ( self . other )
920
+ }
921
+
922
+ /// The value for [`PluralCategory::Few`]
923
+ pub fn few ( & self ) -> & ' a T {
924
+ self . few . unwrap_or ( self . other )
925
+ }
926
+
927
+ /// The value for [`PluralCategory::Many`]
928
+ pub fn many ( & self ) -> & ' a T {
929
+ self . many . unwrap_or ( self . other )
930
+ }
931
+
932
+ /// The value for [`PluralCategory::Other`]
933
+ pub fn other ( & self ) -> & ' a T {
934
+ self . other
935
+ }
936
+
937
+ /// The value used when the [`PluralOperands`] are exactly 0.
938
+ pub fn explicit_zero ( & self ) -> Option < & ' a T > {
939
+ self . explicit_zero
940
+ }
941
+
942
+ /// The value used when the [`PluralOperands`] are exactly 1.
943
+ pub fn explicit_one ( & self ) -> Option < & ' a T > {
944
+ self . explicit_one
945
+ }
946
+
947
+ pub ( crate ) fn has_specials ( & self ) -> bool {
948
+ self . zero . is_some ( )
949
+ || self . one . is_some ( )
950
+ || self . two . is_some ( )
951
+ || self . few . is_some ( )
952
+ || self . many . is_some ( )
953
+ || self . explicit_zero . is_some ( )
954
+ || self . explicit_one . is_some ( )
955
+ }
956
+ }
957
+
958
+ impl < ' a , T : ?Sized + PartialEq > PluralElements < ' a , T > {
907
959
/// Sets the value for [`PluralCategory::Zero`].
908
960
pub fn with_zero_value ( self , zero : Option < & ' a T > ) -> Self {
909
961
Self {
@@ -959,44 +1011,4 @@ impl<'a, T: ?Sized + PartialEq> PluralElements<'a, T> {
959
1011
..self
960
1012
}
961
1013
}
962
-
963
- /// The value for [`PluralCategory::Zero`]
964
- pub fn zero ( & self ) -> & ' a T {
965
- self . zero . unwrap_or ( self . other )
966
- }
967
-
968
- /// The value for [`PluralCategory::One`]
969
- pub fn one ( & self ) -> & ' a T {
970
- self . one . unwrap_or ( self . other )
971
- }
972
-
973
- /// The value for [`PluralCategory::Two`]
974
- pub fn two ( & self ) -> & ' a T {
975
- self . two . unwrap_or ( self . other )
976
- }
977
-
978
- /// The value for [`PluralCategory::Few`]
979
- pub fn few ( & self ) -> & ' a T {
980
- self . few . unwrap_or ( self . other )
981
- }
982
-
983
- /// The value for [`PluralCategory::Many`]
984
- pub fn many ( & self ) -> & ' a T {
985
- self . many . unwrap_or ( self . other )
986
- }
987
-
988
- /// The value for [`PluralCategory::Other`]
989
- pub fn other ( & self ) -> & ' a T {
990
- self . other
991
- }
992
-
993
- /// The value used when the [`PluralOperands`] are exactly 0.
994
- pub fn explicit_zero ( & self ) -> Option < & ' a T > {
995
- self . explicit_zero
996
- }
997
-
998
- /// The value used when the [`PluralOperands`] are exactly 1.
999
- pub fn explicit_one ( & self ) -> Option < & ' a T > {
1000
- self . explicit_one
1001
- }
1002
1014
}
0 commit comments