From 3c92bad9a7cd6b880de197806443ffcce2cac9d8 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 31 Jul 2021 22:59:14 +0200 Subject: Pretty-printed diagnostics with traceback --- src/loading/fs.rs | 7 ++++++- src/loading/mod.rs | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/loading') 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 { + 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 } } -- cgit v1.2.3