mirror of https://github.com/zkat/miette.git
feat(derive): Allow anything Clone + Into<SourceSpan> to be used as a Span
Fixes: https://github.com/zkat/miette/issues/12
This commit is contained in:
parent
26f409c525
commit
385171eb81
|
|
@ -200,14 +200,14 @@ impl Snippets {
|
|||
// Context
|
||||
let context = &snippet.snippet;
|
||||
let context = quote! {
|
||||
context: self.#context.clone(),
|
||||
context: self.#context.clone().into(),
|
||||
};
|
||||
|
||||
// Highlights
|
||||
let highlights = snippet.highlights.iter().map(|highlight| {
|
||||
let Highlight { highlight } = highlight;
|
||||
quote! {
|
||||
self.#highlight.clone()
|
||||
self.#highlight.clone().into()
|
||||
}
|
||||
});
|
||||
let highlights = quote! {
|
||||
|
|
@ -288,7 +288,7 @@ impl Snippets {
|
|||
}
|
||||
};
|
||||
let context = quote! {
|
||||
context: #context.clone(),
|
||||
context: #context.clone().into(),
|
||||
};
|
||||
|
||||
// Highlights
|
||||
|
|
@ -301,7 +301,7 @@ impl Snippets {
|
|||
}
|
||||
};
|
||||
quote! {
|
||||
#m.clone()
|
||||
#m.clone().into()
|
||||
}
|
||||
});
|
||||
let highlights = quote! {
|
||||
|
|
|
|||
|
|
@ -193,9 +193,11 @@ fn test_snippet_named_struct() {
|
|||
// | |
|
||||
// | var 1
|
||||
#[highlight(snip)]
|
||||
var1: SourceSpan, // label from SourceSpan is used, if any.
|
||||
// label from SourceSpan is used, if any.
|
||||
var1: SourceSpan,
|
||||
#[highlight(snip)]
|
||||
var2: SourceSpan,
|
||||
// Anything that's Clone + Into<SourceSpan> can be used here.
|
||||
var2: (String, usize, usize),
|
||||
|
||||
// Now with member source names
|
||||
filename: String,
|
||||
|
|
|
|||
Loading…
Reference in New Issue