Skip to content

feat: add LazyValue::as_cow_str#217

Open
utkarshgupta137 wants to merge 1 commit intocloudwego:mainfrom
utkarshgupta137:main
Open

feat: add LazyValue::as_cow_str#217
utkarshgupta137 wants to merge 1 commit intocloudwego:mainfrom
utkarshgupta137:main

Conversation

@utkarshgupta137
Copy link

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

More detailed description for this PR.

Add LazyValue::as_cow_str to support zero-copy get.

Currently, sonic-rs::get returns LazyValue, but LazyValue::as_str returns &str which is tied to the lifetime of the LazyValue reference instead of the input. This means that even if there are no escapes, we've to copy the str to return the value. LazyValue::as_cow_str returns a Cow<'a, str> which is tied to the lifetime of the input.

@CLAassistant
Copy link

CLAassistant commented Mar 3, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants