Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod named;
pub mod num;
pub mod parse;
pub mod pattern;
pub mod resolution;
#[cfg(feature = "serde")]
mod serde;
pub mod str;
Expand Down
37 changes: 37 additions & 0 deletions src/resolution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::path::Path;
use std::sync::Arc;

/// Powers error reporting by mapping compiler diagnostics to the specific file.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct SourceFile {
/// The name or path of the source file (e.g., "./simf/main.simf").
name: Arc<Path>,
/// The actual text content of the source file.
content: Arc<str>,
}

impl From<(&Path, &str)> for SourceFile {
fn from((name, content): (&Path, &str)) -> Self {
Self {
name: Arc::from(name),
content: Arc::from(content),
}
}
}

impl SourceFile {
pub fn new(name: &Path, content: Arc<str>) -> Self {
Self {
name: Arc::from(name),
content,
}
}

pub fn name(&self) -> &Path {
self.name.as_ref()
}

pub fn content(&self) -> Arc<str> {
self.content.clone()
}
}
Loading