@@ -227,6 +227,7 @@ pub struct Snippet<'a, T> {
227227 pub ( crate ) line_start : usize ,
228228 pub ( crate ) source : Cow < ' a , str > ,
229229 pub ( crate ) markers : Vec < T > ,
230+ pub ( crate ) url : Option < Cow < ' a , str > > ,
230231 pub ( crate ) fold : bool ,
231232}
232233
@@ -246,6 +247,7 @@ impl<'a, T: Clone> Snippet<'a, T> {
246247 line_start : 1 ,
247248 source : source. into ( ) ,
248249 markers : vec ! [ ] ,
250+ url : None ,
249251 fold : true ,
250252 }
251253 }
@@ -271,6 +273,20 @@ impl<'a, T: Clone> Snippet<'a, T> {
271273 self
272274 }
273275
276+ /// The URL to the [`source`][Self::source]. Can be a `file://` URL.
277+ ///
278+ /// <div class="warning">
279+ ///
280+ /// Text passed to this function is considered "untrusted input", as such
281+ /// all text is passed through a normalization function. Pre-styled text is
282+ /// not allowed to be passed to this function.
283+ ///
284+ /// </div>
285+ pub fn url ( mut self , url : impl Into < OptionCow < ' a > > ) -> Self {
286+ self . url = url. into ( ) . 0 ;
287+ self
288+ }
289+
274290 /// Control whether lines without [`Annotation`]s are shown
275291 ///
276292 /// The default is `fold(true)`, collapsing uninteresting lines.
@@ -487,6 +503,7 @@ pub struct Origin<'a> {
487503 pub ( crate ) path : Cow < ' a , str > ,
488504 pub ( crate ) line : Option < usize > ,
489505 pub ( crate ) char_column : Option < usize > ,
506+ pub ( crate ) url : Option < Cow < ' a , str > > ,
490507}
491508
492509impl < ' a > Origin < ' a > {
@@ -502,6 +519,7 @@ impl<'a> Origin<'a> {
502519 path : path. into ( ) ,
503520 line : None ,
504521 char_column : None ,
522+ url : None ,
505523 }
506524 }
507525
@@ -522,6 +540,20 @@ impl<'a> Origin<'a> {
522540 self . char_column = Some ( char_column) ;
523541 self
524542 }
543+
544+ /// The URL to the [`source`][Self::source]. Can be a `file://` URL.
545+ ///
546+ /// <div class="warning">
547+ ///
548+ /// Text passed to this function is considered "untrusted input", as such
549+ /// all text is passed through a normalization function. Pre-styled text is
550+ /// not allowed to be passed to this function.
551+ ///
552+ /// </div>
553+ pub fn url ( mut self , uri : impl Into < Cow < ' a , str > > ) -> Self {
554+ self . url = Some ( uri. into ( ) ) ;
555+ self
556+ }
525557}
526558
527559impl < ' a > From < Cow < ' a , str > > for Origin < ' a > {
0 commit comments