Rename contents to source to match objects that need to store a separate source.

This commit is contained in:
Tom Alexander
2022-12-18 04:40:44 -05:00
parent 448dcfac72
commit 89758721ed
4 changed files with 21 additions and 21 deletions

View File

@@ -28,42 +28,42 @@ pub enum TextElement<'a> {
#[derive(Debug)]
pub struct Span<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct Space<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct LineBreak<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct Symbol<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct BlankLine<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct Sequence<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct Bold<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
pub struct Link<'a> {
pub contents: &'a str,
pub source: &'a str,
}
#[derive(Debug)]
@@ -80,12 +80,12 @@ pub trait Source<'a> {
impl<'a> Source<'a> for TextElement<'a> {
fn get_source(&'a self) -> &'a str {
match self {
TextElement::Span(elem) => elem.contents,
TextElement::Space(elem) => elem.contents,
TextElement::LineBreak(elem) => elem.contents,
TextElement::Symbol(elem) => elem.contents,
TextElement::Bold(elem) => elem.contents,
TextElement::Link(elem) => elem.contents,
TextElement::Span(elem) => elem.source,
TextElement::Space(elem) => elem.source,
TextElement::LineBreak(elem) => elem.source,
TextElement::Symbol(elem) => elem.source,
TextElement::Bold(elem) => elem.source,
TextElement::Link(elem) => elem.source,
}
}
}