From 578d3f7c577e4ac7b075344f7c03e03cd4a09260 Mon Sep 17 00:00:00 2001 From: Hosssein Date: Sun, 10 Dec 2023 17:04:04 +0330 Subject: [PATCH] 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 --- src/std_misc/fs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/std_misc/fs.md b/src/std_misc/fs.md index e078e36edc..ba2d4b4fac 100644 --- a/src/std_misc/fs.md +++ b/src/std_misc/fs.md @@ -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; @@ -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()); });