Browse Source

Add a Source::with_path method to set the path on a Source (#3941)

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

* .

* Align the doc to other with_... methods
pull/3944/head
Hans Larsen 5 months ago committed by GitHub
parent
commit
a9d19bdd22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      core/parser/src/source/mod.rs

8
core/parser/src/source/mod.rs

@ -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

Loading…
Cancel
Save