Comments (9)
IMO it's probably because the inline repr, where the first character can be \0
.
from compact_str.
Sorry if my question was confused. I understand that Repr
's 1st field must be *const
not NonNull
, because 0 is a valid bit pattern for the first 8 bytes of Repr
(e.g. empty string stored inline).
My question was really: Does it matter that HeapBuffer
and StaticStr
's use of NonNull
doesn't match with Repr
, which they get transmuted to?
from compact_str.
My question was really: Does it matter that
HeapBuffer
andStaticStr
's use ofNonNull
doesn't match withRepr
, which they get transmuted to?
Hmmm yeah it gets ignored currently, but I guess maybe in the future it can be changed to take advantage of that?
For example, we can represent empty inline string using ['\0', 1, ..., LENGTH_MASK]
so that the first const ()*
will never be null
, thus enable using NonNull<()>
instead.
from compact_str.
Nice idea. That would deal with the empty string case.
But there is still one weird case where 0 is valid bit pattern for all of 1st 8 bytes: CompactString::new("\0\0\0\0\0\0\0\0")
. I think that rules out using NonNull
in Repr
.
So question is then: Should HeapBuffer
and StaticStr
's first field be changed to *const ()
to match Repr
? Or is it OK that they don't match?
And is there a reason why *const ()
not *const u8
?
from compact_str.
But there is still one weird case where 0 is valid bit pattern for all of 1st 8 bytes:
CompactString::new("\0\0\0\0\0\0\0\0")
. I think that rules out usingNonNull
inRepr
.
Maybe we should treat \0\0
as a special case?
If a string only consists of null bytes , then treat it as empty string?
from compact_str.
Related Issues (20)
- Rethink `new_inline()` and `from_static_str()` HOT 2
- Safer Repr? HOT 6
- CompactString::as_mut_bytes returns a &mut reference to uninitialized bytes HOT 1
- Consider implementing From<CompactString> for std::error::Error HOT 3
- Typo Error
- Dual License with MIT and Apache 2.0 HOT 1
- Merge compact_bytes
- f64::to_compact_string differs from to_string HOT 2
- Align `InlineBuffer` same as `CompactStr` HOT 5
- Improve efficiency of `is_empty` HOT 10
- Add support for holding Arc<str> as a new repr? HOT 3
- Shave an instruction off `len()` HOT 10
- Fuzz Failure! 7662709451 HOT 1
- Fuzz Failure! 7953253492 HOT 1
- Fuzz Failure! 7959979384 HOT 1
- Fuzz Failure! 7967129436 HOT 1
- Fuzz Failure! 7973919521 HOT 1
- Fuzz Failure! 7982539780 HOT 1
- Fuzz Failure! 7989494670 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compact_str.