From b43c044f718b8f5b7026e51dd8c2a56ec9419f75 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 1 Aug 2024 16:22:39 +0200 Subject: [PATCH 1/3] Add a Source::with_path method to set the path on a Source --- 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 5fcf44194e3..dbb51b59ea2 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> { + /// Add a path to the current [`Source`] instance. + pub fn with_path<'path2>(self, new_path: &'path2 Path) -> Self<'path2, R> { + Self { + reader: self.reader, + path: new_path, + } + } + /// Returns the path (if any) of this source file. pub fn path(&self) -> Option<&'path Path> { self.path From b31f4f0a2e76ed1b0a878dc9c050bb995bb1fc6d Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 1 Aug 2024 16:24:53 +0200 Subject: [PATCH 2/3] . --- core/parser/src/source/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/parser/src/source/mod.rs b/core/parser/src/source/mod.rs index dbb51b59ea2..91a2f696ccb 100644 --- a/core/parser/src/source/mod.rs +++ b/core/parser/src/source/mod.rs @@ -121,10 +121,10 @@ impl<'path, R: Read> Source<'path, UTF8Input> { impl<'path, R> Source<'path, R> { /// Add a path to the current [`Source`] instance. - pub fn with_path<'path2>(self, new_path: &'path2 Path) -> Self<'path2, R> { - Self { + pub fn with_path(self, new_path: &Path) -> Source<'_, R> { + Source { reader: self.reader, - path: new_path, + path: Some(new_path), } } From f9ff7c0b21b2eb4065f383aa4618e3f312f3a2b0 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Fri, 2 Aug 2024 21:21:36 +0200 Subject: [PATCH 3/3] Align the doc to other with_... methods --- core/parser/src/source/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/parser/src/source/mod.rs b/core/parser/src/source/mod.rs index 91a2f696ccb..dece67e1374 100644 --- a/core/parser/src/source/mod.rs +++ b/core/parser/src/source/mod.rs @@ -120,7 +120,7 @@ impl<'path, R: Read> Source<'path, UTF8Input> { } impl<'path, R> Source<'path, R> { - /// Add a path to the current [`Source`] instance. + /// Sets the path of this [`Source`]. pub fn with_path(self, new_path: &Path) -> Source<'_, R> { Source { reader: self.reader,