1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#[cfg(not(target_arch = "wasm32"))]
mod native {
pub type LogType = tree_sitter::LogType;
pub type Logger<'a> = Box<dyn FnMut(LogType, &str) + 'a>;
pub struct LoggerReturn<'a, 's> {
#[allow(clippy::borrowed_box, clippy::type_complexity)]
pub inner: &'s Box<dyn FnMut(LogType, &str) + 'a>,
}
impl<'a, 's> LoggerReturn<'a, 's> {
#[allow(clippy::borrowed_box, clippy::type_complexity)]
#[inline]
pub(crate) fn new(inner: &'s Box<dyn FnMut(LogType, &str) + 'a>) -> Self {
Self { inner }
}
}
}
#[cfg(not(target_arch = "wasm32"))]
pub use native::*;
#[cfg(target_arch = "wasm32")]
mod wasm {
use js_sys::JsString;
pub type LogType = JsString;
pub type Logger<'a> = Box<dyn FnMut(LogType, JsString) + 'a>;
pub struct LoggerReturn<'a, 's> {
pub inner: Box<dyn FnMut(LogType, JsString) + 'a>,
phantom: std::marker::PhantomData<&'s ()>,
}
impl<'a, 's> LoggerReturn<'a, 's> {
#[inline]
pub(crate) fn new(inner: Box<dyn FnMut(LogType, JsString) + 'a>) -> Self {
let phantom = std::marker::PhantomData;
Self { inner, phantom }
}
}
}
#[cfg(target_arch = "wasm32")]
pub use wasm::*;