diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-31 22:59:14 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-01 00:00:36 +0200 |
| commit | 3c92bad9a7cd6b880de197806443ffcce2cac9d8 (patch) | |
| tree | 1faf79c66e23bc37711af16ad690a9878e28d348 /src/loading | |
| parent | fbd3d191137aac8188ab8c6503d257d65d873972 (diff) | |
Pretty-printed diagnostics with traceback
Diffstat (limited to 'src/loading')
| -rw-r--r-- | src/loading/fs.rs | 7 | ||||
| -rw-r--r-- | src/loading/mod.rs | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/loading/fs.rs b/src/loading/fs.rs index d41a7dc1..c3ca332e 100644 --- a/src/loading/fs.rs +++ b/src/loading/fs.rs @@ -1,4 +1,4 @@ -use std::cell::RefCell; +use std::cell::{Ref, RefCell}; use std::collections::HashMap; use std::fs::{self, File}; use std::io; @@ -92,6 +92,11 @@ impl FsLoader { } } + /// Return the path of a resolved file. + pub fn path(&self, id: FileId) -> Ref<Path> { + Ref::map(self.paths.borrow(), |paths| paths[&id].as_path()) + } + #[cfg(all(unix, not(target_os = "macos")))] fn search_system_impl(&mut self) { self.search_path("/usr/share/fonts"); diff --git a/src/loading/mod.rs b/src/loading/mod.rs index ab52439d..65eb25c6 100644 --- a/src/loading/mod.rs +++ b/src/loading/mod.rs @@ -40,12 +40,12 @@ pub struct FileId(u64); impl FileId { /// Create a file id from a raw value. - pub fn from_raw(v: u64) -> Self { + pub const fn from_raw(v: u64) -> Self { Self(v) } /// Convert into the raw underlying value. - pub fn into_raw(self) -> u64 { + pub const fn into_raw(self) -> u64 { self.0 } } |
