This crate provide an extension trait for [OpenOptions
] to prevent dereferencing if the given
path is a symbolic link when opening a file.
use nofollow::OpenOptionsExt;
use std::{fs::OpenOptions, io::prelude::*};
let mut content = String::new();
OpenOptions::new()
.read(true)
.no_follow()
.open(file!())
.unwrap()
.read_to_string(&mut content)
.unwrap();
assert_eq!(content, include_str!(concat!("../", file!())));