- ci: Check feat powerset of leon & binstalk-downloader in `ci.yml`
- fix leon feature `cli`: Enable dep `miette` in feature `cli`
- fix binstalk-downloader when default feature is disabled and no other
tls related feature is enabled (breaking change due to replace of
`tls::Version` with newtype `TLSVersion`).
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
If we impl it for `<'f> Fn(&str) -> Option<Cow<'f, str>> + 'f`, then it would somehow imply it to `'static` when using it in `benches/values.rs` and `benches/others.rs`, thus I decided to simplify it back to only implement it for `'static` string.
Users who wants more flexibility should implement `Values` themselves.
This commit also extracts `benches` as a separate crate in an independent workspace to avoid building criterion and tinytemplate in CI, which makes it much slower as more crates need to be built and criterion actually pulls in clap, and a whole lots of other crates.
In additional to that, it:
- Impl `leon::Values` for `Arc<T>` & `Rc<T>` where T: `Values`
- Enable lto, abort on panic, stripping, set `codege-units` to 1 for `leon/benches`
- Move into closure of criterion benchmark loop to reduce indirections
which also reduce sizes of the closure since the Fns used in `ValuesFn`
are zero-size.
This also means that the compiler can now assumes `no-alias`.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
`leon_macros::template!` can parse template at compile-time.
It accepts a utf-8 string literal and uses `leon` internally to parse it, then generate code that evaluates to `Template<'static>`.
- Exclude fuzz from crate leon when publishing
- Impl fn-like proc-macro `leon_macros::template!`
- Add dep `leon-macros` to binstalk
- Use `leon_macros::template!` in `binstalk::fetchers::gh_crate_meta::hosting`
- Add doc for `leon-macros` in `leon`
- Improve `std::fmt::Display` impl for `leon::ParseError`
- Fixed broken infra link in leon
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Fixed#851
* Add new dep leon to crate binstalk
* Add new variant `BinstallError::Template{Parse, Render}Error`
* Use `leon::Template` in mod `bins`
* Use `leon::Template` in mod `fetchers::gh_crate_meta`
* Refactor mod `bins`: Rm unused associated fn & fields from `Context`
* Simplify unit testing in mod `fetchers::gh_crate_meta`
* Rm soft-deprecated field `fetchers::gh_crate_meta::Context::format`
and change the `match` to resolve `archive` => `self.archive_format`.
* Make macro_rules `leon::template!` far easier to use
* Construct `leon::Template<'_>` as constant in `gh_crate_meta::hosting`
* Simplify `leon::Values` trait
Change its method `get_value` signature to
```rust
fn get_value(&self, key: &str) -> Option<Cow<'_, str>>;
```
Now, `ValuesFn` also accepts non-`'static` function, but now
`leon::Values` is only implemented for `&ValuesFn<F>` now.
This makes it a little bit more cumbersome to use but I think it's a
reasonable drawback.
* Rm `Send` bound req from `ValuesFn`
* Impl new fn `leon::Template::cast`
for casting `Template<'s>` to `Template<'t>` where `'s: 't`
* Rename `leon::Template::has_keys` => `has_any_of_keys`
* Make checking whether format related keys are present more robust
* Optimize `GhCrateMeta::launch_baseline_find_tasks`: Skip checking all fmt ext
if none of the format related keys ("format", "archive-format",
"archive-suffix") are present.
* Only ret `.exe` in `PkgFmt::extensions` on windows
by adding a new param `is_windows: bool`
* Improve debug msg in `GhCrateMeta::fetch_and_extract`
* Add warnings to `GhCrateMeta::find`
* Rm dep tinytemplate
* `impl<'s, 'rhs: 's> ops::AddAssign<&Template<'rhs>> for Template<'s>`
* `impl<'s, 'rhs: 's> ops::AddAssign<Template<'rhs>> for Template<'s>`
* `impl<'s, 'item: 's> ops::AddAssign<Item<'item>> for Template<'s>`
* `impl<'s, 'item: 's> ops::AddAssign<&Item<'item>> for Template<'s>`
* `impl<'s, 'rhs: 's> ops::Add<Template<'rhs>> for Template<'s>` (improved existing `Add` impl)
* `impl<'s, 'rhs: 's> ops::Add<&Template<'rhs>> for Template<'s>`
* `impl<'s, 'item: 's> ops::Add<Item<'item>> for Template<'s>`
* `impl<'s, 'item: 's> ops::Add<&Item<'item>> for Template<'s>`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
Replace the algorithm with explicit state and complex matching with a loop that encodes state in the current structure of the loop.
The new code is much more readable and might be more performant since it uses `str::find`/`str::split_once` to look for next token instead of manually iterating over `str::chars`.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* leon: first implementation
* Update crates/leon/src/values.rs
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
* Workaround orphan rules to make API more intuitive
* Fmt
* Clippy
* Use CoW
* Use cow for items too
* Test that const construction works
* leon: Initial attempt at O(n) parser
* leon: finish parser (except escapes)
* leon: Improve ergonomics of compile-time templates
* Document helpers
* leon: Docs tweaks
* leon: Use macro to minimise parser tests
* leon: add escapes to parser
* leon: test escapes preceding keys
* leon: add multibyte tests
* leon: test escapes following keys
* Format
* Debug
* leon: Don't actually need to keep track of the key
* leon: Parse to vec first
* leon: there's actually no need for string cows
* leon: reorganise and redo macro now that there's no coww
* Well that was silly
* leon: Adjust text end when pushing
* leon: catch unbalanced keys
* Add error tests
* leon: Catch unfinished escape
* Comment out debugging
* leon: fuzz
* Clippy
* leon: Box parse error
* leon: &dyn instead of impl
* Can't impl FromStr, so rename to parse
* Add Vec<> to values
* leon: Add benches for ways to supply values
* leon: Add bench comparing to std and tt
* Fix fuzz
* Fmt
* Split ParseError and RenderError
* Make miette optional
* Remove RenderError lifetime
* Simplify ParseError type schema
* Write concrete Values types instead of generics
* Add license files
* Reduce criterion deps
* Make default a cow
* Add a CLI leon tool
* Fix tests
* Clippy
* Disable cli by default
* Avoid failing the build when cli is off
* Add to ci
* Update crates/leon/src/main.rs
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
* Update crates/leon/Cargo.toml
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
* Bump version
* Error not transparent
* Diagnostic can do forwarding
* Simplify error type
* Expand doc examples
* Generic Values for Hash and BTree maps
* One more borrowed
* Forward implementations
* More generics
* Add has_keys
* Lock stdout in leon tool
* No more debug comments in parser
* Even more generics
* Macros to reduce bench duplication
* Further simplify error
* Fix leon main
* Stable support
* Clippy
---------
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>