Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use &str or String instead of &'static str in RenderConfig #95

Closed
arturfast opened this issue Feb 9, 2023 · 1 comment · Fixed by #101
Closed

Use &str or String instead of &'static str in RenderConfig #95

arturfast opened this issue Feb 9, 2023 · 1 comment · Fixed by #101
Milestone

Comments

@arturfast
Copy link

Is your feature request related to a problem? Please describe.
I'd like to customize my prompt prefix in the Text menu using the format! macro. This is not possible due to prompt_prefix being defined as a &'static str in RenderConfig. This is limiting because I can only pass string literals instead of formatted Strings or &str.

Describe the solution you'd like
I'd like to change the parameters of all the fields in RenderConfig, particulary prompt_prefix, to either String or &str. Alternatively I'd like to learn if there is any particular reason for it only accepting string literals.

Describe alternatives you've considered
I have tried various ways to convert a String to a &'static str but they all fail due to lifetimes. Here, here, and here are some of the stackoverflow questions regarding this. I also tried to concatenate string literals and pass the result, without success. Another method I tried was Box::leak(format!("{}", "Hello world").into_boxed_str()); , but it didn't work, and it's a dirty solution that leaks memory.

Additional context

@mikaelmello
Copy link
Owner

I see you, I'll figure something out and make it possible!

@mikaelmello mikaelmello added this to the v1.0.0 milestone Mar 3, 2023
mikaelmello added a commit that referenced this issue Mar 11, 2023
Fixes #95.

This allows render configs to have a custom lifetime, giving more
freedom for further customization on the values, specially those
defined during runtime.
mikaelmello added a commit that referenced this issue Apr 8, 2023
Fixes #95.

This allows render configs to have a custom lifetime, giving more
freedom for further customization on the values, specially those
defined during runtime.
mikaelmello added a commit that referenced this issue Apr 8, 2023
* Allow lifetime customization of RenderConfig

Fixes #95.

This allows render configs to have a custom lifetime, giving more
freedom for further customization on the values, specially those
defined during runtime.

* Add change to changelog

* Remove breaking changes warning for non-breaking change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants