Skip to content

Commit

Permalink
Add a Source::with_path method to set the path on a Source (boa-dev#3941
Browse files Browse the repository at this point in the history
)

* Add a Source::with_path method to set the path on a Source

* .

* Align the doc to other with_... methods
  • Loading branch information
hansl authored Aug 3, 2024
1 parent 6f1d7d1 commit a9d19bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/parser/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ impl<'path, R: Read> Source<'path, UTF8Input<R>> {
}

impl<'path, R> Source<'path, R> {
/// Sets the path of this [`Source`].
pub fn with_path(self, new_path: &Path) -> Source<'_, R> {
Source {
reader: self.reader,
path: Some(new_path),
}
}

/// Returns the path (if any) of this source file.
pub fn path(&self) -> Option<&'path Path> {
self.path
Expand Down

0 comments on commit a9d19bd

Please sign in to comment.