Add borrowed serde support

This commit is contained in:
Isaac Mills 2024-04-10 14:40:00 -04:00
parent ce024a120e
commit 34d350da19
Signed by: fnmain
GPG key ID: B67D7410F33A0F61

View file

@ -13,20 +13,20 @@ use serde::{Deserialize, Serialize};
pub use serde_suck::*;
pub struct JotdownBufferIter<'a, T: Iterator<Item = Event<'a>>> {
djot: T,
indent: Vec<Indent>,
pub djot: T,
pub indent: Vec<Indent>,
}
struct JotdownIntoBuffer<'a, 'b, T: Iterator<Item = Event<'a>>> {
djot: &'b mut T,
attrs: Attrs<'static>,
metrics: Metrics,
indent: &'b mut Vec<Indent>,
image_url: Option<Cow<'a, str>>,
link_start: usize,
urls: Vec<(std::ops::Range<usize>, Cow<'a, str>)>,
location: usize,
added: bool,
pub djot: &'b mut T,
pub attrs: Attrs<'static>,
pub metrics: Metrics,
pub indent: &'b mut Vec<Indent>,
pub image_url: Option<Cow<'a, str>>,
pub link_start: usize,
pub urls: Vec<(std::ops::Range<usize>, Cow<'a, str>)>,
pub location: usize,
pub added: bool,
}
#[derive(Default, Clone, Copy)]
@ -140,10 +140,10 @@ impl<'a, 'b, T: Iterator<Item = Event<'a>>> Iterator for JotdownIntoBuffer<'a, '
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct RichText<'a>(
Cow<'a, str>,
pub Cow<'a, str>,
#[cfg_attr(feature = "serde", serde(with = "AttrsSerde"))]
#[cfg_attr(feature = "serde", serde(borrow))]
Attrs<'a>,
pub Attrs<'a>,
);
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]