From a9d19bdd22d9d5af124198e2d1916a38f6da7cf5 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Sat, 3 Aug 2024 13:46:38 -0700 Subject: [PATCH] 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 --- core/parser/src/source/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/parser/src/source/mod.rs b/core/parser/src/source/mod.rs index 5fcf44194e..dece67e137 100644 --- a/core/parser/src/source/mod.rs +++ b/core/parser/src/source/mod.rs @@ -120,6 +120,14 @@ impl<'path, R: Read> Source<'path, UTF8Input> { } 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