@@ -352,15 +352,15 @@ impl Display for FilePermissions {
352352 }
353353}
354354
355- impl From < String > for FilePermissions {
356- fn from ( s : String ) -> Self {
357- Self ( s)
358- }
359- }
355+ impl TryFrom < & OsStr > for FilePermissions {
356+ type Error = ( ) ;
360357
361- impl From < & OsStr > for FilePermissions {
362- fn from ( s : & OsStr ) -> Self {
363- Self ( s. to_string_lossy ( ) . into_owned ( ) )
358+ fn try_from ( s : & OsStr ) -> Result < Self , Self :: Error > {
359+ if s == "." {
360+ Err ( ( ) )
361+ } else {
362+ Ok ( Self ( s. to_string_lossy ( ) . into_owned ( ) ) )
363+ }
364364 }
365365}
366366
@@ -760,8 +760,8 @@ pub(crate) fn parse_args() -> Mode {
760760 display_path. to_string_lossy ( ) . to_string ( ) ,
761761 FileArgument :: from_path_argument ( lhs_tmp_file) ,
762762 FileArgument :: from_path_argument ( rhs_tmp_file) ,
763- Some ( ( * lhs_mode) . into ( ) ) ,
764- Some ( ( * rhs_mode) . into ( ) ) ,
763+ FilePermissions :: try_from ( * lhs_mode) . ok ( ) ,
764+ FilePermissions :: try_from ( * rhs_mode) . ok ( ) ,
765765 None ,
766766 )
767767 }
@@ -778,8 +778,8 @@ pub(crate) fn parse_args() -> Mode {
778778 new_name,
779779 FileArgument :: from_path_argument ( lhs_tmp_file) ,
780780 FileArgument :: from_path_argument ( rhs_tmp_file) ,
781- Some ( ( * lhs_mode) . into ( ) ) ,
782- Some ( ( * rhs_mode) . into ( ) ) ,
781+ FilePermissions :: try_from ( * lhs_mode) . ok ( ) ,
782+ FilePermissions :: try_from ( * rhs_mode) . ok ( ) ,
783783 Some ( renamed) ,
784784 )
785785 }
0 commit comments