fix(rust): compilation on wasm32-wasi

This commit is contained in:
Mark McCulloh 2024-04-13 18:30:41 -04:00 committed by GitHub
parent 9ba8f6dfe6
commit a7a47d561d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -8,7 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(not(feature = "bindgen"))]
include!("./bindings.rs");
#[cfg(unix)]
#[cfg(not(windows))]
extern "C" {
pub(crate) fn _ts_dup(fd: std::os::raw::c_int) -> std::os::raw::c_int;
}

View file

@ -3,8 +3,8 @@
pub mod ffi;
mod util;
#[cfg(unix)]
use std::os::unix::io::AsRawFd;
#[cfg(not(windows))]
use std::os::fd::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;
use std::{
@ -942,10 +942,10 @@ impl Tree {
#[doc(alias = "ts_tree_print_dot_graph")]
pub fn print_dot_graph(
&self,
#[cfg(unix)] file: &impl AsRawFd,
#[cfg(not(windows))] file: &impl AsRawFd,
#[cfg(windows)] file: &impl AsRawHandle,
) {
#[cfg(unix)]
#[cfg(not(windows))]
{
let fd = file.as_raw_fd();
unsafe { ffi::ts_tree_print_dot_graph(self.0.as_ptr(), fd) }