Skip to content

Commit 578d3f7

Browse files
Update example fs.md and use target_family instead of target_os
using target_family make code more compatible with different types of unix systems
1 parent 933c339 commit 578d3f7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/std_misc/fs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::fs;
77
use std::fs::{File, OpenOptions};
88
use std::io;
99
use std::io::prelude::*;
10-
#[cfg(target_os = "unix")]
10+
#[cfg(target_family = "unix")]
1111
use std::os::unix;
12-
#[cfg(target_os = "windows")]
12+
#[cfg(target_family = "windows")]
1313
use std::os::windows;
1414
use std::path::Path;
1515
@@ -65,12 +65,12 @@ fn main() {
6565
6666
println!("`ln -s ../b.txt a/c/b.txt`");
6767
// Create a symbolic link, returns `io::Result<()>`
68-
#[cfg(target_os = "unix")] {
68+
#[cfg(target_family = "unix")] {
6969
unix::fs::symlink("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
7070
println!("! {:?}", why.kind());
7171
});
7272
}
73-
#[cfg(target_os = "windows")] {
73+
#[cfg(target_family = "windows")] {
7474
windows::fs::symlink_file("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
7575
println!("! {:?}", why.to_string());
7676
});

0 commit comments

Comments
 (0)