pub struct ConfigSnippet {
pub lines: Vec<SnippetLine>,
pub error_line: Option<usize>,
pub highlight_range: Option<(usize, usize)>,
}Expand description
A snippet of config file content with context.
Fields§
§lines: Vec<SnippetLine>Lines of the snippet with their line numbers.
error_line: Option<usize>The line number that contains the error.
highlight_range: Option<(usize, usize)>Column range to highlight on the error line.
Implementations§
Source§impl ConfigSnippet
impl ConfigSnippet
Sourcepub fn from_content(
content: &str,
error_line: usize,
context_lines: usize,
) -> Self
pub fn from_content( content: &str, error_line: usize, context_lines: usize, ) -> Self
Create a snippet from file content around a specific line.
Sourcepub fn single_line(line_num: usize, content: impl Into<String>) -> Self
pub fn single_line(line_num: usize, content: impl Into<String>) -> Self
Create a snippet from a single line.
Sourcepub fn with_highlight(self, start: usize, end: usize) -> Self
pub fn with_highlight(self, start: usize, end: usize) -> Self
Set the highlight range on the error line.
Trait Implementations§
Source§impl Clone for ConfigSnippet
impl Clone for ConfigSnippet
Source§fn clone(&self) -> ConfigSnippet
fn clone(&self) -> ConfigSnippet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigSnippet
impl Debug for ConfigSnippet
Source§impl<'de> Deserialize<'de> for ConfigSnippet
impl<'de> Deserialize<'de> for ConfigSnippet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConfigSnippet
impl RefUnwindSafe for ConfigSnippet
impl Send for ConfigSnippet
impl Sync for ConfigSnippet
impl Unpin for ConfigSnippet
impl UnsafeUnpin for ConfigSnippet
impl UnwindSafe for ConfigSnippet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more