File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1200,7 +1200,7 @@ impl TomlManifest {
1200
1200
) ?;
1201
1201
1202
1202
let readme = match & project. readme {
1203
- None => Some ( String :: from ( "README.md" ) ) ,
1203
+ None => default_readme_from_package_root ( package_root ) ,
1204
1204
Some ( value) => match value. as_str ( ) {
1205
1205
"false" => None ,
1206
1206
_ => Some ( value. clone ( ) )
@@ -1522,6 +1522,19 @@ impl TomlManifest {
1522
1522
}
1523
1523
}
1524
1524
1525
+ const DEFAULT_README_FILES : [ & str ; 3 ] = [ "README.md" , "README.txt" , "README" ] ;
1526
+
1527
+ /// Checks if a file with any of the default README file names exists in the package root.
1528
+ /// If so, returns a String representing that name.
1529
+ fn default_readme_from_package_root ( package_root : & Path ) -> Option < String > {
1530
+ DEFAULT_README_FILES
1531
+ . iter ( )
1532
+ . map ( |& fname| package_root. join ( Path :: new ( fname) ) )
1533
+ . filter ( |path| path. is_file ( ) )
1534
+ . flat_map ( |path| path. file_name ( ) . map ( |fname| fname. to_string_lossy ( ) . into_owned ( ) ) )
1535
+ . nth ( 0 )
1536
+ }
1537
+
1525
1538
/// Checks a list of build targets, and ensures the target names are unique within a vector.
1526
1539
/// If not, the name of the offending build target is returned.
1527
1540
fn unique_build_targets ( targets : & [ Target ] , package_root : & Path ) -> Result < ( ) , String > {
You can’t perform that action at this time.
0 commit comments