File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ fn main() {
5
5
. with_prompt ( "Password" )
6
6
. with_confirmation ( "Repeat password" , "Error: the passwords don't match." )
7
7
. validate_with ( |input : & String | -> Result < ( ) , & str > {
8
- if input. len ( ) > 3 {
8
+ if input. chars ( ) . count ( ) > 3 {
9
9
Ok ( ( ) )
10
10
} else {
11
11
Err ( "Password must be longer than 3" )
@@ -14,5 +14,8 @@ fn main() {
14
14
. interact ( )
15
15
. unwrap ( ) ;
16
16
17
- println ! ( "Your password is {} characters long" , password. len( ) ) ;
17
+ println ! (
18
+ "Your password is {} characters long" ,
19
+ password. chars( ) . count( )
20
+ ) ;
18
21
}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ impl Password<'_> {
86
86
87
87
/// Enables user interaction and returns the result.
88
88
///
89
- /// If the user confirms the result is `true `, `false ` otherwise.
89
+ /// If the user confirms the result is `Ok() `, `Err() ` otherwise.
90
90
/// The dialog is rendered on stderr.
91
91
pub fn interact ( self ) -> Result < String > {
92
92
self . interact_on ( & Term :: stderr ( ) )
@@ -159,7 +159,7 @@ impl<'a> Password<'a> {
159
159
/// let password: String = Password::new()
160
160
/// .with_prompt("Enter password")
161
161
/// .validate_with(|input: &String| -> Result<(), &str> {
162
- /// if input.len () > 8 {
162
+ /// if input.chars().count () > 8 {
163
163
/// Ok(())
164
164
/// } else {
165
165
/// Err("Password must be longer than 8")
You can’t perform that action at this time.
0 commit comments