File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ fn main() {
4
4
let password = Password :: with_theme ( & ColorfulTheme :: default ( ) )
5
5
. with_prompt ( "Password" )
6
6
. with_confirmation ( "Repeat password" , "Error: the passwords don't match." )
7
- . validate_with ( |input : & str | -> Result < ( ) , & str > {
7
+ . validate_with ( |input : & String | -> Result < ( ) , & str > {
8
8
if input. len ( ) > 3 {
9
9
Ok ( ( ) )
10
10
} else {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use crate::{
8
8
use console:: Term ;
9
9
use zeroize:: Zeroizing ;
10
10
11
- type PasswordValidatorCallback < ' a > = Box < dyn Fn ( & str ) -> Option < String > + ' a > ;
11
+ type PasswordValidatorCallback < ' a > = Box < dyn Fn ( & String ) -> Option < String > + ' a > ;
12
12
13
13
/// Renders a password input prompt.
14
14
///
@@ -87,7 +87,7 @@ impl<'a> Password<'a> {
87
87
/// # use dialoguer::Password;
88
88
/// let password: String = Password::new()
89
89
/// .with_prompt("Enter password")
90
- /// .validate_with(|input: &str | -> Result<(), &str> {
90
+ /// .validate_with(|input: &String | -> Result<(), &str> {
91
91
/// if input.len() > 8 {
92
92
/// Ok(())
93
93
/// } else {
@@ -104,7 +104,7 @@ impl<'a> Password<'a> {
104
104
{
105
105
let old_validator_func = self . validator . take ( ) ;
106
106
107
- self . validator = Some ( Box :: new ( move |value : & str | -> Option < String > {
107
+ self . validator = Some ( Box :: new ( move |value : & String | -> Option < String > {
108
108
if let Some ( old) = & old_validator_func {
109
109
if let Some ( err) = old ( value) {
110
110
return Some ( err) ;
Original file line number Diff line number Diff line change @@ -26,23 +26,24 @@ where
26
26
}
27
27
28
28
/// Trait for password validators.
29
+ #[ allow( clippy:: ptr_arg) ]
29
30
pub trait PasswordValidator {
30
31
type Err ;
31
32
32
33
/// Invoked with the value to validate.
33
34
///
34
35
/// If this produces `Ok(())` then the value is used and parsed, if
35
36
/// an error is returned validation fails with that error.
36
- fn validate ( & self , input : & str ) -> Result < ( ) , Self :: Err > ;
37
+ fn validate ( & self , input : & String ) -> Result < ( ) , Self :: Err > ;
37
38
}
38
39
39
40
impl < F , E > PasswordValidator for F
40
41
where
41
- F : Fn ( & str ) -> Result < ( ) , E > ,
42
+ F : Fn ( & String ) -> Result < ( ) , E > ,
42
43
{
43
44
type Err = E ;
44
45
45
- fn validate ( & self , input : & str ) -> Result < ( ) , Self :: Err > {
46
+ fn validate ( & self , input : & String ) -> Result < ( ) , Self :: Err > {
46
47
self ( input)
47
48
}
48
49
}
You can’t perform that action at this time.
0 commit comments