Skip to content

Commit

Permalink
lib: rename RenderRef::*_borrowed -> RenderRef::*_ref
Browse files Browse the repository at this point in the history
match name of trait and similarly named methods like get_ref, as_ref
etc.
  • Loading branch information
hellux committed Aug 2, 2024
1 parent b867840 commit 1242485
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions bench/criterion/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ fn gen_html(c: &mut criterion::Criterion) {
}
criterion_group!(html, gen_html);

fn gen_html_borrow(c: &mut criterion::Criterion) {
let mut group = c.benchmark_group("html_borrow");
fn gen_html_ref(c: &mut criterion::Criterion) {
let mut group = c.benchmark_group("html_ref");
for (name, input) in bench_input::INPUTS {
group.throughput(criterion::Throughput::Elements(
jotdown::Parser::new(input).count() as u64,
Expand All @@ -72,7 +72,7 @@ fn gen_html_borrow(c: &mut criterion::Criterion) {
use jotdown::RenderRef;
let mut s = String::new();
jotdown::html::Renderer::default()
.push_borrowed(p.as_slice().iter(), &mut s)
.push_ref(p.as_slice().iter(), &mut s)
.unwrap();
s
},
Expand All @@ -82,7 +82,7 @@ fn gen_html_borrow(c: &mut criterion::Criterion) {
);
}
}
criterion_group!(html_borrow, gen_html_borrow);
criterion_group!(html_ref, gen_html_ref);

fn gen_html_clone(c: &mut criterion::Criterion) {
let mut group = c.benchmark_group("html_clone");
Expand Down Expand Up @@ -122,4 +122,4 @@ fn gen_full(c: &mut criterion::Criterion) {
}
criterion_group!(full, gen_full);

criterion_main!(block, inline, html, html_borrow, html_clone, full);
criterion_main!(block, inline, html, html_ref, html_clone, full);
2 changes: 1 addition & 1 deletion src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Render for Renderer {
}

impl RenderRef for Renderer {
fn push_borrowed<'s, E, I, W>(&self, mut events: I, mut out: W) -> std::fmt::Result
fn push_ref<'s, E, I, W>(&self, mut events: I, mut out: W) -> std::fmt::Result
where
E: AsRef<Event<'s>>,
I: Iterator<Item = E>,
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ pub trait RenderRef {
/// # let events: &[jotdown::Event] = &[];
/// let mut output = String::new();
/// let renderer = jotdown::html::Renderer::default();
/// renderer.push_borrowed(events.iter(), &mut output);
/// renderer.push_ref(events.iter(), &mut output);
/// # }
/// ```
fn push_borrowed<'s, E, I, W>(&self, events: I, out: W) -> fmt::Result
fn push_ref<'s, E, I, W>(&self, events: I, out: W) -> fmt::Result
where
E: AsRef<Event<'s>>,
I: Iterator<Item = E>,
Expand All @@ -158,7 +158,7 @@ pub trait RenderRef {
///
/// NOTE: This performs many small writes, so IO writes should be buffered with e.g.
/// [`std::io::BufWriter`].
fn write_borrowed<'s, E, I, W>(&self, events: I, out: W) -> io::Result<()>
fn write_ref<'s, E, I, W>(&self, events: I, out: W) -> io::Result<()>
where
E: AsRef<Event<'s>>,
I: Iterator<Item = E>,
Expand All @@ -169,7 +169,7 @@ pub trait RenderRef {
error: Ok(()),
};

self.push_borrowed(events, &mut out)
self.push_ref(events, &mut out)
.map_err(|_| match out.error {
Err(e) => e,
_ => io::Error::new(io::ErrorKind::Other, "formatter error"),
Expand Down

0 comments on commit 1242485

Please sign in to comment.