Replace `String` engine parameters with `impl AsRef<str>`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 346
- Forks
- 75
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 15
Description
Hey 👋
Most Engine struct parameters that accept strings in their parameters mainly use String, which requires unneccessary heap allocations in scenarios where a simple &'static str will do. For instance, Engine::add_policy's example may be written to the following assuming that impl AsRef<str> is used instead of String; note how to_string() has been removed:
let mut engine = Engine::new();
let package = engine.add_policy(
"test.rego",
r#"
package test
allow = input.user == "root"
"#)?;
assert_eq!(package, "data.test");
I am happy to contribute this change myself if you guys want to go ahead with the suggestion.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Engine API and the Engine::add_policy documentation example. Audit the other Engine parameters that accept String, then review the relevant tests and API compatibility. Done means string literals can be passed without to_string() wherever the change applies, with tests and documentation still passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100