mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
chore: 🤖 make FileSystem trait object safe (#1157)
This commit is contained in:
parent
3b88f748fd
commit
7c8342d6be
3 changed files with 9 additions and 6 deletions
|
|
@ -25,7 +25,7 @@ pub struct Cache<Fs> {
|
|||
tsconfigs: DashMap<PathBuf, Arc<TsConfig>, BuildHasherDefault<FxHasher>>,
|
||||
}
|
||||
|
||||
impl<Fs: FileSystem> Cache<Fs> {
|
||||
impl<Fs: FileSystem + Default> Cache<Fs> {
|
||||
pub fn new(fs: Fs) -> Self {
|
||||
Self { fs, ..Self::default() }
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ impl CachedPathImpl {
|
|||
.map(|r| r.unwrap_or_else(|| self.path.clone().to_path_buf()))
|
||||
}
|
||||
|
||||
pub fn module_directory<Fs: FileSystem>(
|
||||
pub fn module_directory<Fs: FileSystem + Default>(
|
||||
&self,
|
||||
module_name: &str,
|
||||
cache: &Cache<Fs>,
|
||||
|
|
@ -224,7 +224,10 @@ impl CachedPathImpl {
|
|||
cached_path.is_dir(&cache.fs).then(|| cached_path)
|
||||
}
|
||||
|
||||
pub fn cached_node_modules<Fs: FileSystem>(&self, cache: &Cache<Fs>) -> Option<CachedPath> {
|
||||
pub fn cached_node_modules<Fs: FileSystem + Default>(
|
||||
&self,
|
||||
cache: &Cache<Fs>,
|
||||
) -> Option<CachedPath> {
|
||||
self.node_modules.get_or_init(|| self.module_directory("node_modules", cache)).clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
};
|
||||
|
||||
/// File System abstraction used for `ResolverGeneric`.
|
||||
pub trait FileSystem: Default + Send + Sync {
|
||||
pub trait FileSystem: Send + Sync {
|
||||
/// See [std::fs::read_to_string]
|
||||
///
|
||||
/// # Errors
|
||||
|
|
|
|||
|
|
@ -134,13 +134,13 @@ struct ResolveContextImpl {
|
|||
depth: u8,
|
||||
}
|
||||
|
||||
impl<Fs: FileSystem> Default for ResolverGeneric<Fs> {
|
||||
impl<Fs: FileSystem + Default> Default for ResolverGeneric<Fs> {
|
||||
fn default() -> Self {
|
||||
Self::new(ResolveOptions::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<Fs: FileSystem> ResolverGeneric<Fs> {
|
||||
impl<Fs: FileSystem + Default> ResolverGeneric<Fs> {
|
||||
pub fn new(options: ResolveOptions) -> Self {
|
||||
#[cfg(feature = "tracing-subscriber")]
|
||||
tracing_subscriber::init();
|
||||
|
|
|
|||
Loading…
Reference in a new issue