You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Rust 1.77.0, C-string literals have been stabilized and can be created with c"foo".
As such, using CStrs are easy to create, and I believe we should aim to be as zero-cost as possible when it comes to our bindings.
Applying format_compact! to a str is a non-zero cost operation, even if the str is small.
My intuition tells be 90% of the time when using &'a str, 'a is 'static.
This would also allow us to unify the APIs that have two functions: one that takes a &str and one that takes a &CStr. There are many functions
that do not even have a c_str equivalent, and this is personally an issue for me.
I also am slightly against the idea of using generics to accept CStr and str. Again, this will make newcomers more likely to use the much less efficient &str everywhere
when it makes no sense to do so.
The text was updated successfully, but these errors were encountered:
This used to be &CStr, but from alpha user experience, I noticed it's not ideal and people are too unfamiliar with it. With compact string, the cost has been greatly reduced in most cases and thus it shouldn't be an issue in 99.9% of the cases considering the fact you aren't likely to use names in hot path code, but more likely setup code.
In the future we can consider some sort of Into trait to support both.
In Rust 1.77.0, C-string literals have been stabilized and can be created with
c"foo"
.As such, using CStrs are easy to create, and I believe we should aim to be as zero-cost as possible when it comes to our bindings.
format_compact!
to astr
is a non-zero cost operation, even if the str is small.&'a str
,'a
is'static
.This would also allow us to unify the APIs that have two functions: one that takes a
&str
and one that takes a&CStr
. There are many functionsthat do not even have a
c_str
equivalent, and this is personally an issue for me.I also am slightly against the idea of using generics to accept CStr and str. Again, this will make newcomers more likely to use the much less efficient
&str
everywherewhen it makes no sense to do so.
The text was updated successfully, but these errors were encountered: