@@ -20,9 +20,9 @@ pub enum Teletype {
20
20
impl Display for Teletype {
21
21
fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
22
22
match self {
23
- Self :: Tty ( id) => write ! ( f, "/dev/pts/ {id}" ) ,
24
- Self :: TtyS ( id) => write ! ( f, "/dev/tty {id}" ) ,
25
- Self :: Pts ( id) => write ! ( f, "/dev/ttyS {id}" ) ,
23
+ Self :: Tty ( id) => write ! ( f, "/dev/tty {id}" ) ,
24
+ Self :: TtyS ( id) => write ! ( f, "/dev/ttyS {id}" ) ,
25
+ Self :: Pts ( id) => write ! ( f, "/dev/pts/ {id}" ) ,
26
26
Self :: Unknown => write ! ( f, "?" ) ,
27
27
}
28
28
}
@@ -32,10 +32,6 @@ impl TryFrom<String> for Teletype {
32
32
type Error = ( ) ;
33
33
34
34
fn try_from ( value : String ) -> Result < Self , Self :: Error > {
35
- if value == "?" {
36
- return Ok ( Self :: Unknown ) ;
37
- }
38
-
39
35
Self :: try_from ( value. as_str ( ) )
40
36
}
41
37
}
@@ -44,6 +40,10 @@ impl TryFrom<&str> for Teletype {
44
40
type Error = ( ) ;
45
41
46
42
fn try_from ( value : & str ) -> Result < Self , Self :: Error > {
43
+ if value == "?" {
44
+ return Ok ( Self :: Unknown ) ;
45
+ }
46
+
47
47
Self :: try_from ( PathBuf :: from ( value) )
48
48
}
49
49
}
0 commit comments