@@ -43,7 +43,7 @@ impl fmt::Display for PersonnummerError {
43
43
impl Error for PersonnummerError { }
44
44
45
45
#[ allow( dead_code) ]
46
- /// Personnummer holds relevant data to check for valid personal identity numbers.
46
+ /// [ Personnummer] holds relevant data to check for valid personal identity numbers.
47
47
pub struct Personnummer {
48
48
date : chrono:: NaiveDate ,
49
49
serial : u32 ,
@@ -52,7 +52,7 @@ pub struct Personnummer {
52
52
coordination : bool ,
53
53
}
54
54
55
- /// FormattedPersonnummer holds two formats of a normalized personal identity number, one long and
55
+ /// [ FormattedPersonnummer] holds two formats of a normalized personal identity number, one long and
56
56
/// one short format. The long format displays the full century while the short format only
57
57
/// displays the year.
58
58
pub struct FormattedPersonnummer {
@@ -61,12 +61,12 @@ pub struct FormattedPersonnummer {
61
61
}
62
62
63
63
impl FormattedPersonnummer {
64
- /// Returns the long format of a formatted personal identity number as a String.
64
+ /// Returns the long format of a formatted personal identity number as a [ String] .
65
65
pub fn long ( & self ) -> String {
66
66
self . long . clone ( )
67
67
}
68
68
69
- /// Returns the short format of a formatted personal identity number as a String.
69
+ /// Returns the short format of a formatted personal identity number as a [ String] .
70
70
pub fn short ( & self ) -> String {
71
71
self . short . clone ( )
72
72
}
@@ -127,19 +127,19 @@ impl TryFrom<&str> for Personnummer {
127
127
}
128
128
129
129
impl Personnummer {
130
- /// Returns a new instance of a Personnummer. Panics for invalid dates but not for invalid
131
- /// personal identity numbers. Use valid() to check validity.
130
+ /// Returns a new instance of a [ Personnummer] . Panics for invalid dates but not for invalid
131
+ /// personal identity numbers. Use [Personnummer:: valid()] to check validity.
132
132
pub fn new ( pnr : & str ) -> Result < Personnummer , PersonnummerError > {
133
133
Personnummer :: try_from ( pnr)
134
134
}
135
135
136
- /// Same as new() but returns an Option instead of panicing on invalid dates.
136
+ /// Same as [Personnummer:: new()] but returns an [ Option] instead of panicing on invalid dates.
137
137
pub fn parse ( pnr : & str ) -> Result < Personnummer , PersonnummerError > {
138
138
Personnummer :: try_from ( pnr)
139
139
}
140
140
141
- /// Returns a FormattedPersonnummer from a Personnummer which can be used to display a
142
- /// normalized version of the Personnummer.
141
+ /// Returns a [ FormattedPersonnummer] from a [ Personnummer] which can be used to display a
142
+ /// normalized version of the [ Personnummer] .
143
143
pub fn format ( & self ) -> FormattedPersonnummer {
144
144
let day = self . date . day ( ) ;
145
145
let day_or_coordination = if self . coordination {
@@ -162,7 +162,7 @@ impl Personnummer {
162
162
FormattedPersonnummer { long, short }
163
163
}
164
164
165
- /// Validate a Personnummer. The validation requires a valid date and that the Luhn checksum
165
+ /// Validate a [ Personnummer] . The validation requires a valid date and that the Luhn checksum
166
166
/// matches the control digit.
167
167
pub fn valid ( & self ) -> bool {
168
168
let ymd = format ! (
@@ -206,17 +206,17 @@ impl Personnummer {
206
206
self . coordination
207
207
}
208
208
209
- /// Year of date of birth.
209
+ /// Year of birth date .
210
210
pub fn year ( & self ) -> i32 {
211
211
self . date . year ( )
212
212
}
213
213
214
- /// Month of date of birth.
214
+ /// Month of birth date .
215
215
pub fn month ( & self ) -> u32 {
216
216
self . date . month ( )
217
217
}
218
218
219
- /// Day of date of birth.
219
+ /// Day of birth date .
220
220
pub fn day ( & self ) -> u32 {
221
221
self . date . day ( )
222
222
}
0 commit comments