@@ -20,9 +20,9 @@ pub enum Teletype {
2020impl Display for Teletype {
2121 fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
2222 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}" ) ,
2626 Self :: Unknown => write ! ( f, "?" ) ,
2727 }
2828 }
@@ -32,10 +32,6 @@ impl TryFrom<String> for Teletype {
3232 type Error = ( ) ;
3333
3434 fn try_from ( value : String ) -> Result < Self , Self :: Error > {
35- if value == "?" {
36- return Ok ( Self :: Unknown ) ;
37- }
38-
3935 Self :: try_from ( value. as_str ( ) )
4036 }
4137}
@@ -44,6 +40,10 @@ impl TryFrom<&str> for Teletype {
4440 type Error = ( ) ;
4541
4642 fn try_from ( value : & str ) -> Result < Self , Self :: Error > {
43+ if value == "?" {
44+ return Ok ( Self :: Unknown ) ;
45+ }
46+
4747 Self :: try_from ( PathBuf :: from ( value) )
4848 }
4949}
0 commit comments