Skip to content

Bug fix and improvement idea #12

Description

@callframe

I forked this repository and made a couple of changes that better fit my own use case. Before I keep maintaining them locally, I wanted to ask whether you'd be interested in upstreaming them.

no_std support

I made the crate no_std-compatible (using only core and alloc), which allows it to be used in bare-metal and embedded environments. This is a requirement for my own projects, as I generally design my libraries to avoid depending on std unless it is actually required.

The change itself was fairly small and mostly consisted of replacing std imports with their core/alloc equivalents.

Allow passing &str to Renderer::arg

While integrating the crate, I ran into an issue where Renderer::arg could not accept a &str obtained from APIs such as AsRef<str>::as_ref().

For example:

let s: &str = "hello";
renderer.arg(s); // does not compile

The reason is that the parameter type is &(impl Display + Debug), which implicitly requires the hidden type to be Sized. In this case the compiler infers T = str, which is unsized, even though str implements both Display and Debug.

The existing tests didn't expose this because the string arguments were passed in forms that inferred T = &str (effectively passing &&str), which satisfies the implicit Sized bound.

To fix this, I changed the internal argument representation so that borrowed string slices are handled explicitly while all other values continue to be stored as trait objects. This allows Renderer::arg to accept &str naturally without changing the public API or introducing allocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions