feat(api): add StringValue::from_static_str#3540
Conversation
Make it possible to create a StringValue at compile time
|
|
||
| impl StringValue { | ||
| /// Create a new const `StringValue`. | ||
| pub const fn from_static_str(value: &'static str) -> Self { |
There was a problem hiding this comment.
Could we add a small doctest showing the actual const use case here?
There was a problem hiding this comment.
Unfortunately, we can't make a KeyValue at compile time with the current initializer. I changed the example.
| impl StringValue { | ||
| /// Create a new const `StringValue`. | ||
| /// | ||
| /// This is useful for making static label values: |
There was a problem hiding this comment.
let labels = &[KeyValue::new("key", "value")];
^ couldn't we already this today?
|
Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience. It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open. |
Changes
Add
StringValue::from_static_str, make it possible to create a StringValue at compile time.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes