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

Consider impl From<&str> for KString #16

Closed
mateuszkj opened this issue Oct 27, 2021 · 1 comment
Closed

Consider impl From<&str> for KString #16

mateuszkj opened this issue Oct 27, 2021 · 1 comment

Comments

@mateuszkj
Copy link

I got error while trying to into() from no static str

fn str_to_kstring(s: &str) -> KString {
    s.into()
}

assert_eq!(str_to_kstring("test"), KString::from_ref("test"));

Error

79 |             s.into()
   |               ^^^^ lifetime `'static` required

liquid-rust version:
rust version: rustc 1.56.0 (09c42c458 2021-10-18)
OS: Linux mk-Precision-Tower-7910 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@epage
Copy link
Member

epage commented Oct 27, 2021

This is intentional. KString is effectively a smarter Cow<'static, str> and we want to provide an easy path for people to get their &'static str into it.

@epage epage closed this as completed Oct 27, 2021
epage added a commit to epage/kstring that referenced this issue Apr 26, 2024
…n-3.x

chore(deps): Update pre-commit/action action to v3.0.1
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

No branches or pull requests

2 participants