Skip to content

Commit

Permalink
Replace const_cstr!(...) with c"..." CStr literals
Browse files Browse the repository at this point in the history
Summary: Supported since Rust 1.77: https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html#c-string-literals

Reviewed By: zertosh

Differential Revision: D59988483

fbshipit-source-id: 756d79612d6d281ce5dbc7973037a5fdb9526f40
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Jul 20, 2024
1 parent c9c1697 commit 852e08e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion reverie-process/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ thiserror = "1.0.49"
tokio = { version = "1.37.0", features = ["full", "test-util", "tracing"] }

[dev-dependencies]
const-cstr = "0.3.0"
num_cpus = "1.16"
raw-cpuid = "10.6.0"
tempfile = "3.8"
Expand Down
22 changes: 6 additions & 16 deletions reverie-process/src/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,6 @@ mod tests {
use std::ffi::CString;
use std::os::unix::ffi::OsStrExt;

use const_cstr::const_cstr;

use super::*;

#[test]
Expand All @@ -537,24 +535,16 @@ mod tests {

#[test]
fn test_is_dir() {
assert!(is_dir(const_cstr!("/").as_ptr()));
assert!(is_dir(const_cstr!("/dev").as_ptr()));
assert!(!is_dir(const_cstr!("/dev/null").as_ptr()));
assert!(is_dir(c"/".as_ptr()));
assert!(is_dir(c"/dev".as_ptr()));
assert!(!is_dir(c"/dev/null".as_ptr()));
}

#[test]
fn test_file_type() {
assert!(FileType::new(const_cstr!("/").as_ptr()).unwrap().is_dir());
assert!(
FileType::new(const_cstr!("/dev").as_ptr())
.unwrap()
.is_dir()
);
assert!(
!FileType::new(const_cstr!("/dev/null").as_ptr())
.unwrap()
.is_file()
);
assert!(FileType::new(c"/".as_ptr()).unwrap().is_dir());
assert!(FileType::new(c"/dev".as_ptr()).unwrap().is_dir());
assert!(!FileType::new(c"/dev/null".as_ptr()).unwrap().is_file());
}

#[test]
Expand Down

0 comments on commit 852e08e

Please sign in to comment.