tealdeer-rs / tealdeer

A very fast implementation of tldr in Rust.
https://tealdeer-rs.github.io/tealdeer/
Apache License 2.0
4.17k stars 123 forks source link

Concatenate page and patch bytes before processing #238

Closed dbrgn closed 2 years ago

dbrgn commented 2 years ago

This way a patch file does not need a well-formed header anymore.

Fixes #181 and thus the last open feature/bug issue for the 1.5.0 milestone! 🎉

Replaces #202.

niklasmohrin commented 2 years ago

We could avoid the dynamic dispatch if we use https://docs.rs/either/latest/either/enum.Either.html#impl-Read, don't know if it is overkill though

dbrgn commented 2 years ago

Whoa, I didn't know that Either has a blanket-Read-impl. This is nice!

dbrgn commented 2 years ago

Ahh, wait, Either is a separate crate and not in the stdlib. Then I don't think it's worth the added dependency 🙂

dbrgn commented 2 years ago

Great, I'll merge this once CI passes. Thanks @dmaahs2017 and @niklasmohrin for the review and comments! I think the patch system will be a very useful feature in the next release.

niklasmohrin commented 2 years ago

Fair enough - we can always come back to this thought if we feel like optimizing

dbrgn commented 2 years ago

Hehe, as_slice() was added only in Rust 1.57, which hasn't been stable for a month (as per our MSRV policy). I'll use &b"\n"[..] unless there's a better way.