Skip to content

Commit

Permalink
Update example fs.md and use target_family instead of target_os
Browse files Browse the repository at this point in the history
using target_family make code more compatible with different types of unix systems
  • Loading branch information
HosseinAssaran authored Dec 10, 2023
1 parent 933c339 commit 578d3f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/std_misc/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::fs;
use std::fs::{File, OpenOptions};
use std::io;
use std::io::prelude::*;
#[cfg(target_os = "unix")]
#[cfg(target_family = "unix")]
use std::os::unix;
#[cfg(target_os = "windows")]
#[cfg(target_family = "windows")]
use std::os::windows;
use std::path::Path;
Expand Down Expand Up @@ -65,12 +65,12 @@ fn main() {
println!("`ln -s ../b.txt a/c/b.txt`");
// Create a symbolic link, returns `io::Result<()>`
#[cfg(target_os = "unix")] {
#[cfg(target_family = "unix")] {
unix::fs::symlink("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
println!("! {:?}", why.kind());
});
}
#[cfg(target_os = "windows")] {
#[cfg(target_family = "windows")] {
windows::fs::symlink_file("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
println!("! {:?}", why.to_string());
});
Expand Down

0 comments on commit 578d3f7

Please sign in to comment.