commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
e0bca1b5cd2c2b7d1a44a38df1e618638e1f0c61 | Parker Timmerman | 2022-03-06T22:36:39 | add proptests for Cow | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index fd8811e6..9e464977 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -532,6 +532,12 @@ impl PartialEq<CompactStr> for &str {
}
}
+impl<'a> PartialEq<CompactStr> for Cow<'a, str> {
+ fn eq(&self, other: &CompactStr) -> bool {... | 2 | 22 | 0 |
f8e0e7ddd084ac605c188960b236b24ca4ec401d | Mike Cronce | 2022-02-28T18:43:56 | src/lib.rs: impl From<Cow<'_, str>> for CompactStr | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 4568e934..29f7c75c 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -26,6 +26,7 @@ use core::str::{
FromStr,
Utf8Error,
};
+use std::borrow::Cow;
mod asserts;
mod features;
@@ -567,6 +568,12 @@ impl<'a> From<&'a String>... | 1 | 7 | 0 |
aeb719ea2d40b17773cc57c8b3ab3d7e3a6fa717 | Parker Timmerman | 2022-02-28T15:24:37 | have examples use v0.3 | diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index 41e87d52..d26fb4ac 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2018"
[dependencies]
bytes = "1"
-compact_str = { path = "../../compact_str", features = ["bytes"] }
+compact_str = { version ... | 2 | 2 | 2 |
0434cf50b4ce77d580eb07cba30bb499e82e023b | Parker Timmerman | 2022-02-27T21:47:16 | cargo fmt | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 75ce2858..8b2251f6 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -208,8 +208,8 @@ impl CompactStr {
/// This method converts from an arbitrary contiguous collection of bytes into a [`CompactStr`],
/// failing if the provi... | 2 | 3 | 3 |
751d8592ee1f97ad6b6d78e0cd46f108de458290 | Parker Timmerman | 2022-02-27T21:43:40 | add property testing and fuzz testing | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 5b353f20..d55d43ca 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -74,6 +74,29 @@ proptest! {
prop_assert_eq!(&word, &compact);
}
+ #[test]
+ #[cfg_attr(miri, ignore)]
+ fn test_from_bytes_roundtrips... | 2 | 48 | 3 |
9cc231cfe9113b4a6c6327ca5be0ba1df4287ab2 | Parker Timmerman | 2022-02-27T21:34:37 | branch start, add from_utf8 API | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index e74eda5e..75ce2858 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -22,7 +22,10 @@ use core::hash::{
};
use core::iter::FromIterator;
use core::ops::Deref;
-use core::str::FromStr;
+use core::str::{
+ FromStr,
+ Utf8Error,
+... | 2 | 46 | 1 |
a1de77975f1862434e650d49787865abe61c7480 | Parker Timmerman | 2022-02-27T21:03:21 | small doc comment change | diff --git a/compact_str/src/repr/heap.rs b/compact_str/src/repr/heap.rs
index 1d3c0113..c68790c5 100644
--- a/compact_str/src/repr/heap.rs
+++ b/compact_str/src/repr/heap.rs
@@ -49,8 +49,7 @@ impl HeapString {
HeapString { padding, string }
}
- /// Makes a mutable reference to the underlying buffer,... | 1 | 1 | 2 |
0768a44d5473588832b45cd91be970a4f4f8f361 | Parker Timmerman | 2022-02-19T21:31:13 | branch start, BoxedString | diff --git a/compact_str/src/repr/arc/mod.rs b/compact_str/src/repr/arc/mod.rs
index 0b07328a..fdea33b7 100644
--- a/compact_str/src/repr/arc/mod.rs
+++ b/compact_str/src/repr/arc/mod.rs
@@ -1,3 +1,6 @@
+// TODO: Use this module
+#![allow(dead_code)]
+
use std::iter::Extend;
use std::sync::atomic::Ordering;
use std:... | 5 | 465 | 8 |
19d6dd3e5f1ac185aeae886ee51c98d1680749ca | Parker Timmerman | 2022-02-15T15:44:18 | delete fuzz/unit.rs, use forked version of arbitrary | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index b8ae58c7..abe406d8 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -9,7 +9,7 @@ edition = "2018"
cargo-fuzz = true
[dependencies]
-arbitrary = { version = "1", features = ["derive"] }
+arbitrary = { git = "https://github.com/ParkMyCar/arbitrary.git", branch... | 2 | 1 | 35 |
78dcb02f5623a475dbd75c5c760c7ae911109edf | Parker Timmerman | 2022-02-14T15:56:23 | whoops, forgot to add the bin file | diff --git a/fuzz/src/bin/unit.rs b/fuzz/src/bin/unit.rs
new file mode 100644
index 00000000..6e03f0e2
--- /dev/null
+++ b/fuzz/src/bin/unit.rs
@@ -0,0 +1,27 @@
+use arbitrary::{
+ Arbitrary,
+ Unstructured,
+};
+use compact_str_fuzz::Scenario;
+
+pub fn main() {
+ let input_file = std::env::args().nth(1).expe... | 1 | 27 | 0 |
e1fbe31ed9d5a442ea35af1d74b82fb51a5147d6 | Parker Timmerman | 2022-02-12T18:05:52 | forgot to commit the new bin file | diff --git a/fuzz/src/bin/afl.rs b/fuzz/src/bin/afl.rs
new file mode 100644
index 00000000..34abfac0
--- /dev/null
+++ b/fuzz/src/bin/afl.rs
@@ -0,0 +1,18 @@
+use afl::fuzz;
+use compact_str_fuzz::Scenario;
+
+pub fn main() {
+ fuzz!(|scenario: Scenario<'_>| {
+ // Given random creation method, if we can crea... | 1 | 18 | 0 |
9a2eae10a2afdbcafab555a0a4750c0f5bd7861d | Parker Timmerman | 2022-02-12T17:59:15 | make fuzzing libraries optional, so we only build them when necessary | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index e36dda35..13c09071 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -9,20 +9,24 @@ edition = "2018"
cargo-fuzz = true
[dependencies]
-afl = "0.12.1"
arbitrary = { version = "1", features = ["derive"] }
bytes = "1"
compact_str = { path = "../compact_str", ... | 1 | 6 | 2 |
9e7fece6bf27b93eb6be443d9e6acd8b0b6ae5e2 | Parker Timmerman | 2022-02-12T17:39:07 | branch start, add afl as dep, add afl target | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index cf6deedc..e36dda35 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -9,6 +9,7 @@ edition = "2018"
cargo-fuzz = true
[dependencies]
+afl = "0.12.1"
arbitrary = { version = "1", features = ["derive"] }
bytes = "1"
compact_str = { path = "../compact_str", fe... | 1 | 7 | 0 |
465991d6e9503925de907c2be96faf9867076f67 | Parker Timmerman | 2022-02-12T17:14:16 | fuzz creation from non-contiguous bytes with VecDeque | diff --git a/compact_str/src/repr/bytes.rs b/compact_str/src/repr/bytes.rs
index 13e48991..f4d5da6a 100644
--- a/compact_str/src/repr/bytes.rs
+++ b/compact_str/src/repr/bytes.rs
@@ -4,7 +4,6 @@ use bytes::Buf;
use super::{
Repr,
- HEAP_MASK,
MAX_SIZE,
};
@@ -49,7 +48,7 @@ impl Repr {
... | 3 | 67 | 26 |
e8694590e7cb276b5aa80c74ac16d36e2b4c0962 | Parker Timmerman | 2022-02-12T04:50:49 | branch start | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index c93594de..cf6deedc 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -10,6 +10,7 @@ cargo-fuzz = true
[dependencies]
arbitrary = { version = "1", features = ["derive"] }
+bytes = "1"
compact_str = { path = "../compact_str", features = ["bytes"] }
libfuzzer-... | 3 | 25 | 0 |
fc905887ba1913ffa50bb551311d24fd4ccb4d79 | Parker Timmerman | 2022-02-09T04:13:32 | fix rust edition in bench crate | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 9065d4a9..9e225c27 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "benches"
version = "0.1.0"
-edition = "2021"
+edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifes... | 1 | 1 | 1 |
92fae2f5a6889da464f05165eecf88b83c7c4a07 | Parker Timmerman | 2022-02-09T02:56:53 | cargo fmt | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 98c9702e..1efc828d 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -113,9 +113,10 @@ crate::asserts::assert_size_eq!(InlineString, String);
#[cfg(test)]
mod tests {
- use proptest::prelude::*;
... | 1 | 2 | 1 |
294315936cb5480b260da19a2ebb20d352da4269 | Parker Timmerman | 2022-02-09T02:54:46 | fix tests for 32bit, use char::try_from(...) which is available on rustc 1.49 | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 510fc089..98c9702e 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -114,6 +114,7 @@ crate::asserts::assert_size_eq!(InlineString, String);
#[cfg(test)]
mod tests {
use proptest::prelude::*;
+ ... | 2 | 4 | 5 |
df07ae78eee0a69b961855df9f5a1059a8dcf183 | Parker Timmerman | 2022-02-09T02:45:04 | update comment | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 3bd8e070..c64843bd 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -211,7 +211,7 @@ fn test_medium_ascii() {
fn test_medium_unicode() {
let strs = vec![
("☕️👀😁🎉", false),
- // str is 24 bytes long, an... | 1 | 1 | 1 |
c9223b52d145f70b3a88a290d549f30b38835d7d | Parker Timmerman | 2022-02-08T20:17:45 | fix issues with from_buf and from_iterator methods, uncomment the fuzzing | diff --git a/compact_str/benches/random.rs b/compact_str/benches/random.rs
index e1a627b9..edfcdaa9 100644
--- a/compact_str/benches/random.rs
+++ b/compact_str/benches/random.rs
@@ -13,11 +13,7 @@ fn if_statement_min(c: &mut Criterion) {
c.bench_function("if statement min", |b| {
b.iter(|| {
... | 5 | 105 | 87 |
ead7f6f882aff8e99841d523a3e6f6969d6daabf | Parker Timmerman | 2022-02-08T18:11:32 | in progress, get rid of the Packed variant | diff --git a/compact_str/fuzz/fuzz_targets/creation.rs b/compact_str/fuzz/fuzz_targets/creation.rs
index 839a9751..f89d9a2a 100644
--- a/compact_str/fuzz/fuzz_targets/creation.rs
+++ b/compact_str/fuzz/fuzz_targets/creation.rs
@@ -10,14 +10,14 @@ use libfuzzer_sys::fuzz_target;
const MAX_INLINE_LENGTH: usize = std::me... | 8 | 145 | 316 |
a176a360ad1d674650d6cfa00604f4ed851fa9f2 | Parker Timmerman | 2022-02-05T05:19:21 | bit of cleanup | diff --git a/compact_str/src/repr/discriminant.rs b/compact_str/src/repr/discriminant.rs
index c4b9bd84..bd494983 100644
--- a/compact_str/src/repr/discriminant.rs
+++ b/compact_str/src/repr/discriminant.rs
@@ -1,6 +1,5 @@
use super::{
HEAP_MASK,
- LEADING_BIT_MASK,
MAX_SIZE,
};
diff --git a/compact_st... | 3 | 1 | 13 |
8e5b0b9e62f518d5fc35d8bf1aaeb79bef1f4825 | Parker Timmerman | 2022-02-05T05:02:39 | add random benchmarks target to benchmark little bits of code | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 15852c0c..43fde2f6 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -38,3 +38,7 @@ harness = false
[[bench]]
name = "comparison"
harness = false
+
+[[bench]]
+name = "random"
+harness = false
diff --git a/compact_str/benches/random... | 3 | 46 | 1 |
ec3435eb343c94a2dae679fa2452c61bc8e829ce | Parker Timmerman | 2022-02-05T04:53:48 | branch start, refactor InlineString with sanity checks, rest of tests are broken | diff --git a/compact_str/fuzz/fuzz_targets/creation.rs b/compact_str/fuzz/fuzz_targets/creation.rs
index 8ee1b3f8..839a9751 100644
--- a/compact_str/fuzz/fuzz_targets/creation.rs
+++ b/compact_str/fuzz/fuzz_targets/creation.rs
@@ -29,7 +29,7 @@ fuzz_target!(|method: CreationMethod<'_>| {
// assert the Comp... | 8 | 152 | 55 |
091a0b2d95a5f884e92978dd07d8367ba2903ef9 | Parker Timmerman | 2022-01-24T03:45:20 | branch start, vendor static assertions | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index b442c993..15852c0c 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -16,7 +16,6 @@ categories = ["encoding", "parsing", "memory-management", "text-processing"]
[dependencies]
bytes = { version = "1", optional = true }
serde = { ver... | 9 | 52 | 15 |
91a77a04ffc9a343c1698cb502d0e5f12b80f793 | Parker Timmerman | 2022-01-19T15:14:47 | small change | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 9981913e..54d594d2 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -210,8 +210,8 @@ impl CompactStr {
/// let ascii = CompactStr::new("hello world");
/// assert_eq!(ascii.len(), 11);
///
- /// let person = CompactSt... | 1 | 2 | 2 |
63a082eadb0761369649edde7c81ac1b3ded22e9 | Parker Timmerman | 2022-01-19T15:07:30 | cargo fmt | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index f0167b04..9981913e 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -191,7 +191,6 @@ impl CompactStr {
/// "packed" representation. Creating a `CompactStr` with capacity of `size_of::<String>()` will
/// heap allocate, becau... | 1 | 0 | 2 |
1c338d8485da0b7603aed55491a7032712c24b30 | Parker Timmerman | 2022-01-19T15:06:35 | more docs | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index 6b1478a3..69da4f13 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -44,8 +44,8 @@ impl CompactStr {
///
/// # Safety
/// This function is unsafe because it does not check tha... | 2 | 53 | 7 |
9373eb0e4fa4f8304ca8bfbc15d13b42b3b54bd8 | Parker Timmerman | 2022-01-19T04:17:47 | add more documentation | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index d62ddd9a..7e5b91c9 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -32,15 +32,16 @@ use repr::Repr;
#[cfg(test)]
mod tests;
-/// A `CompactStr` is a compact string tupe that can be used almost anywhere a `String` or `&str`
-/// c... | 2 | 86 | 25 |
8fa944776898bc6c6fa2ea7f40f03a2f87033f30 | Parker Timmerman | 2022-01-18T15:17:58 | add more docs | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index def635a0..d62ddd9a 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -78,21 +78,6 @@ impl CompactStr {
/// short enough, then it will be inlined on the stack!
///
/// # Examples
- /// ```
- /// use compact_str::Com... | 1 | 37 | 16 |
09d033d8b23d2edfb275116093f41ddf23824920 | Parker Timmerman | 2022-01-18T03:58:56 | branch start, improve documentation, add with_capacity method | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index e280766b..def635a0 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1,5 +1,5 @@
-//! `CompactStr` is a compact immutable string type that stores itself on the stack, if possible,
-//! and seamlessly interacts with `String`s and `&str... | 4 | 170 | 8 |
5da3a9d9b394103d55d5379bff249da8c24556a4 | Parker Timmerman | 2022-01-17T23:48:51 | use a u16 to limit pops further | diff --git a/compact_str/fuzz/fuzz_targets/modify.rs b/compact_str/fuzz/fuzz_targets/modify.rs
index c6357b66..a7a5867e 100644
--- a/compact_str/fuzz/fuzz_targets/modify.rs
+++ b/compact_str/fuzz/fuzz_targets/modify.rs
@@ -24,7 +24,8 @@ fuzz_target!(|scenario: Scenario| {
#[derive(Arbitrary, Debug)]
enum Modification... | 1 | 2 | 1 |
a3e03b1a4206a3ba7486b9466f5d31dcc8ffa22b | Parker Timmerman | 2022-01-17T23:46:03 | limit number of pops in fuzz target modify to u32 | diff --git a/compact_str/fuzz/fuzz_targets/modify.rs b/compact_str/fuzz/fuzz_targets/modify.rs
index ea7006b4..c6357b66 100644
--- a/compact_str/fuzz/fuzz_targets/modify.rs
+++ b/compact_str/fuzz/fuzz_targets/modify.rs
@@ -24,7 +24,7 @@ fuzz_target!(|scenario: Scenario| {
#[derive(Arbitrary, Debug)]
enum Modification... | 2 | 14 | 1 |
a79ef0bcba15be85c02c43551924dc40fd94881e | Parker Timmerman | 2022-01-17T18:29:34 | fix lifetime issue | diff --git a/compact_str/src/repr/arc/writer.rs b/compact_str/src/repr/arc/writer.rs
index 55e83d49..377386a0 100644
--- a/compact_str/src/repr/arc/writer.rs
+++ b/compact_str/src/repr/arc/writer.rs
@@ -101,7 +101,7 @@ impl<'a> ArcStringWriter<'a> {
/// # SAFETY
/// * Callers must guarantee that any modificat... | 1 | 1 | 1 |
8c34e1c991a576fd23a4e53e8af51a4438e88057 | Parker Timmerman | 2022-01-17T18:26:17 | whoops, messed up the cfg_attr | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 296bd1f3..a2aacda7 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -239,7 +239,7 @@ fn test_from_char_iter() {
}
#[test]
-#[cfg_attr(target_pointer_width = 32, ignore)]
+#[cfg_attr(target_pointer_width = "32", ignore)]
f... | 1 | 1 | 1 |
64e09ba3dbb0495f55546f6d503fbcf0cb4f15be | Parker Timmerman | 2022-01-17T18:24:46 | ignore test on 32bit archs | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 9c46eafe..296bd1f3 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -239,6 +239,7 @@ fn test_from_char_iter() {
}
#[test]
+#[cfg_attr(target_pointer_width = 32, ignore)]
fn test_extend_packed_from_empty() {
let s = "... | 1 | 1 | 0 |
8fc0204a7b07616f4e66b767738469e4922e52af | Parker Timmerman | 2022-01-16T18:38:15 | update fuzz target modify to pop a specified number of characters | diff --git a/compact_str/fuzz/fuzz_targets/modify.rs b/compact_str/fuzz/fuzz_targets/modify.rs
index 09ddd00c..ea7006b4 100644
--- a/compact_str/fuzz/fuzz_targets/modify.rs
+++ b/compact_str/fuzz/fuzz_targets/modify.rs
@@ -24,7 +24,7 @@ fuzz_target!(|scenario: Scenario| {
#[derive(Arbitrary, Debug)]
enum Modification... | 1 | 10 | 5 |
05bf72d1258bc906867113099b3d62fe7bbec177 | Parker Timmerman | 2022-01-14T22:54:48 | reorganize repr::heap module, make repr::arc module, partial re-write of repr::Extend impl | diff --git a/compact_str/src/repr/arc/inner.rs b/compact_str/src/repr/arc/inner.rs
new file mode 100644
index 00000000..eef6aee6
--- /dev/null
+++ b/compact_str/src/repr/arc/inner.rs
@@ -0,0 +1,90 @@
+use core::sync::atomic::AtomicUsize;
+use core::{
+ ptr,
+ slice,
+};
+use std::alloc;
+
+const UNKNOWN: usize = ... | 6 | 432 | 119 |
d4322ab6ee3d0b5e0a6a6fe9bdf1c6cb03a85856 | Parker Timmerman | 2022-01-14T17:36:43 | get rid of unused reserve API, cargo clippy, cargo fmt, update benchmarks | diff --git a/compact_str/benches/apis.rs b/compact_str/benches/apis.rs
index 84c12b13..c1544714 100644
--- a/compact_str/benches/apis.rs
+++ b/compact_str/benches/apis.rs
@@ -65,13 +65,16 @@ fn compact_str_clone_small(c: &mut Criterion) {
c.bench_function("clone small", |b| b.iter(|| compact.clone()));
}
-fn co... | 4 | 28 | 37 |
a1446bb19d2ea67fe715359da59201e00598a298 | Parker Timmerman | 2022-01-14T16:42:56 | update benchmarks, inline some methods | diff --git a/compact_str/benches/compact_str.rs b/compact_str/benches/compact_str.rs
index 4e381e84..e543ba73 100644
--- a/compact_str/benches/compact_str.rs
+++ b/compact_str/benches/compact_str.rs
@@ -25,5 +25,10 @@ fn heap(c: &mut Criterion) {
c.bench_function("heap", |b| b.iter(|| CompactStr::new(word)));
}
... | 4 | 15 | 9 |
2e2a65b546adcaf0c0a9209840cf3692b737936f | Parker Timmerman | 2022-01-12T19:59:42 | add some more benchmarks | diff --git a/compact_str/benches/apis.rs b/compact_str/benches/apis.rs
index 9bc5768f..84c12b13 100644
--- a/compact_str/benches/apis.rs
+++ b/compact_str/benches/apis.rs
@@ -60,6 +60,20 @@ fn compact_str_reserve_large(c: &mut Criterion) {
});
}
+fn compact_str_clone_small(c: &mut Criterion) {
+ let compact ... | 1 | 33 | 1 |
ae4ad1f2810134f643c5bc845ebb1a6526099cac | Parker Timmerman | 2022-01-12T19:59:18 | allocate more memory when resizing | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 5c349cea..83d34bc3 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -29,8 +29,15 @@ impl ArcString {
#[inline]
pub fn new(text: &str, additional: usize) -> Self {
let len = te... | 1 | 9 | 2 |
7daffd8d6aa0f070d8b3a96181549dc01d114162 | Parker Timmerman | 2022-01-12T06:27:28 | add fuzzing target, fix popping from a Packed repr | diff --git a/compact_str/fuzz/Cargo.toml b/compact_str/fuzz/Cargo.toml
index d2f99964..80a4e74e 100644
--- a/compact_str/fuzz/Cargo.toml
+++ b/compact_str/fuzz/Cargo.toml
@@ -21,3 +21,9 @@ name = "creation"
path = "fuzz_targets/creation.rs"
test = false
doc = false
+
+[[bin]]
+name = "modify"
+path = "fuzz_targets/m... | 3 | 104 | 1 |
8bd99d7f7c916a4aea66b222d56076beee9bd69c | Parker Timmerman | 2022-01-12T05:45:38 | MVP push and pop CompactStr | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 30967d27..e280766b 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -161,6 +161,21 @@ impl CompactStr {
self.repr.as_mut_slice()
}
+ #[inline]
+ pub fn push(&mut self, ch: char) {
+ self.repr.push(ch)
+ ... | 3 | 179 | 134 |
bbf8ad0e0af8e4fb7dcabee6c84235929f308f50 | Parker Timmerman | 2022-01-12T05:16:32 | branch start, reserve, push, and pop, APIs | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 949b6f8c..b38a5eaf 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -1,3 +1,4 @@
+use std::iter::Extend;
use std::sync::atomic::{
AtomicUsize,
Ordering,
@@ -44,6 +45,23 @@ impl ArcStr... | 2 | 152 | 1 |
e82915743e749d9a405068c00251bc8312dc28b0 | Parker Timmerman | 2022-01-09T19:32:57 | clippy and fmt | diff --git a/compact_str/fuzz/fuzz_targets/creation.rs b/compact_str/fuzz/fuzz_targets/creation.rs
index 0f726908..8ee1b3f8 100644
--- a/compact_str/fuzz/fuzz_targets/creation.rs
+++ b/compact_str/fuzz/fuzz_targets/creation.rs
@@ -1,9 +1,11 @@
#![no_main]
+#![allow(clippy::if_same_then_else)]
+
+use std::io::Cursor;
... | 1 | 7 | 5 |
14ee63f9d859e5969864e495594cf502e4106de7 | Parker Timmerman | 2022-01-09T19:18:13 | make one fuzz target for CompactStr creation | diff --git a/compact_str/fuzz/Cargo.toml b/compact_str/fuzz/Cargo.toml
index 1b2cc7ba..d2f99964 100644
--- a/compact_str/fuzz/Cargo.toml
+++ b/compact_str/fuzz/Cargo.toml
@@ -9,6 +9,7 @@ edition = "2018"
cargo-fuzz = true
[dependencies]
+arbitrary = { version = "1", features = ["derive"] }
libfuzzer-sys = "0.4"
... | 5 | 98 | 87 |
3ff1bea0ba455b8e1a3f0fcb3038325a63655cab | Parker Timmerman | 2022-01-08T23:55:16 | reduce the number of runs in alloc test | diff --git a/compact_str/tests/alloc.rs b/compact_str/tests/alloc.rs
index 1ebcb127..1dcca489 100644
--- a/compact_str/tests/alloc.rs
+++ b/compact_str/tests/alloc.rs
@@ -22,8 +22,8 @@ fn test_randomized_allocations() {
eprintln!("using seed: {}_u64", seed);
let mut rng = StdRng::seed_from_u64(seed);
- /... | 1 | 2 | 2 |
18bf8adcf6186f5f16c8435f1bca194adf10e418 | Parker Timmerman | 2022-01-08T23:14:27 | small doc comment update | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index ca0fa551..6b1478a3 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -50,12 +50,11 @@ impl CompactStr {
/// # Examples
/// ```
/// # use compact_str::CompactStr;
- /// use s... | 1 | 3 | 4 |
852801aa24ad6060c09e1b291a1f734c9a1ca493 | Parker Timmerman | 2022-01-08T23:12:52 | fix MSRV issue in doc tests | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index eb6fd447..ca0fa551 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -17,7 +17,7 @@ impl CompactStr {
/// # use std::collections::VecDeque;
///
/// // `bytes::Buf` is implement... | 1 | 1 | 1 |
ce680c7847ec6a17f5bb42f43181bdd107461d0a | Parker Timmerman | 2022-01-08T22:34:18 | expose as_slice(...) on CompactStr | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 01364325..30967d27 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -133,6 +133,11 @@ impl CompactStr {
self.repr.as_str()
}
+ #[inline]
+ pub fn as_slice(&self) -> &[u8] {
+ self.repr.as_slice()
+ }
+
... | 1 | 5 | 0 |
33d1bddef766b3e2d3549fbc82bce36a0f07c79c | Parker Timmerman | 2022-01-08T19:31:23 | fix edition issue in bytes example | diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index 91f5fd11..41e87d52 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "bytes"
version = "0.1.0"
-edition = "2021"
+edition = "2018"
# See more keys and their definitions at https://doc.rus... | 1 | 1 | 1 |
f486a9f28c836efea7dfd0832886984c043d87a0 | Parker Timmerman | 2022-01-08T19:30:23 | clippy fixes | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index c102ae11..eb6fd447 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -42,10 +42,10 @@ impl CompactStr {
/// Converts a buffer of bytes to a `CompactStr`, without checking that the provid... | 3 | 7 | 6 |
dd94227df65bb8b5c152a85a9637a130e648f23c | Parker Timmerman | 2022-01-08T19:28:54 | fix TODO: add as_slice() method to Repr | diff --git a/compact_str/src/repr/bytes.rs b/compact_str/src/repr/bytes.rs
index 675b94fa..fb552e31 100644
--- a/compact_str/src/repr/bytes.rs
+++ b/compact_str/src/repr/bytes.rs
@@ -21,15 +21,16 @@ impl Repr {
let repr = unsafe { Self::from_utf8_buf_unchecked(buf) };
// Check to make sure the provi... | 5 | 36 | 11 |
891ec917d2d2a13d91513cd2d810d54c6c971975 | Parker Timmerman | 2022-01-08T19:20:57 | add doc tests for the bytes APIs | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index 25cff988..c102ae11 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -9,12 +9,57 @@ use crate::{
impl CompactStr {
/// Converts a buffer of bytes to a `CompactStr`
+ ///
+ /// #... | 1 | 45 | 0 |
87a611e7793d96c1a6ababb6804c3e4fb001d122 | Parker Timmerman | 2022-01-08T19:06:29 | provide from_utf8_buf_unchecked API | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index d7a3c70a..25cff988 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -12,6 +12,13 @@ impl CompactStr {
pub fn from_utf8_buf<B: Buf>(buf: &mut B) -> Result<Self, Utf8Error> {
Rep... | 2 | 28 | 13 |
6c42dc617e05c0ad47ce7ea119a1574952a6ba54 | Parker Timmerman | 2022-01-08T18:58:03 | add bytes example | diff --git a/Cargo.toml b/Cargo.toml
index d934e31f..c2da6b3c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,2 +1,2 @@
[workspace]
-members = ["examples/serde", "compact_str", "tracing_alloc"]
+members = ["examples/bytes", "examples/serde", "compact_str", "tracing_alloc"]
diff --git a/examples/bytes/Cargo.toml b/examp... | 3 | 26 | 1 |
a8c9384f9646e1d12f318eae71c4df8d1fc9b9c0 | Parker Timmerman | 2022-01-03T23:03:04 | fix issue with edition 2021, and type issue with 32-bit archs | diff --git a/compact_str/src/repr/bytes.rs b/compact_str/src/repr/bytes.rs
index 4ccf9ce7..4dc0c546 100644
--- a/compact_str/src/repr/bytes.rs
+++ b/compact_str/src/repr/bytes.rs
@@ -8,7 +8,7 @@ use super::{
};
#[cfg(target_pointer_width = "32")]
-const DEFAULT_TEXT: str = "000000000000";
+const DEFAULT_TEXT: &str ... | 2 | 2 | 2 |
d3fb90dc114a63ff22775fd52091ebcf47e08f1f | Parker Timmerman | 2022-01-03T22:56:11 | some clippy fixes | diff --git a/Cargo.toml b/Cargo.toml
index 81baf451..62233f6d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,2 +1,2 @@
[workspace]
-members = ["examples/pb-jelly","examples/pb-jelly/gen","examples/pb-jelly/protos/gen/proto_user", "examples/serde", "compact_str", "tracing_alloc"]
+members = ["examples/pb-jelly", "examp... | 3 | 4 | 2 |
537422e8e3a45ee2dd48a7e22ad71854dcf53c02 | Parker Timmerman | 2022-01-03T22:50:51 | clippy and fmt fixes | diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs
index ee89fa50..d7a3c70a 100644
--- a/compact_str/src/features/bytes.rs
+++ b/compact_str/src/features/bytes.rs
@@ -16,16 +16,19 @@ impl CompactStr {
#[cfg(test)]
mod test {
- use crate::CompactStr;
+ use std::io::Cursor;
+
... | 3 | 7 | 6 |
6240dfb8943a80b34adab4b0b2e987e5d8be4a9a | Parker Timmerman | 2022-01-03T20:21:23 | MVP, adding bytes feature, using this to make pb-jelly impl | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 20f13268..af624400 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -14,6 +14,7 @@ categories = ["encoding", "parsing", "memory-management", "text-processing"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/... | 6 | 209 | 3 |
702393c0a2319843227adcc8fabc6e61129af6a4 | Parker Timmerman | 2022-01-03T19:02:41 | branch start, some scafolding | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 0ca96f03..20f13268 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -14,6 +14,7 @@ categories = ["encoding", "parsing", "memory-management", "text-processing"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/... | 5 | 28 | 4 |
03123b239f90b651793f4032d91e92375da4ef2f | Parker Timmerman | 2022-01-03T22:42:12 | fix bug in make_mut_slice when we're the sole reference | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 86a9c393..3b1c8ef8 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -78,7 +78,10 @@ impl ArcString {
// Assign self to our new instsance
*self = new;
- };
+ ... | 2 | 5 | 2 |
94b730e7cb3832feec75f395689c07aeaa42d29e | Parker Timmerman | 2022-01-03T18:55:23 | add proptest for reserve and write apis | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index afd2d486..82596313 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -153,7 +153,7 @@ impl CompactStr {
/// * All Rust strings, including `CompactStr`, must be valid UTF-8. The caller must guarantee
/// that any modifications... | 3 | 47 | 2 |
a81611a797ee19fac8b5be3c93f65c48782ffb30 | Parker Timmerman | 2022-01-03T16:49:26 | add set_len API | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 277c5dac..afd2d486 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -157,6 +157,13 @@ impl CompactStr {
self.repr.as_mut_slice()
}
+ /// # Safety
+ /// * TODO: Document safety here
+ #[inline]
+ pub unsafe ... | 6 | 97 | 16 |
e9f242ac7627c76d33a833e7fcc75462365c8d4c | Parker Timmerman | 2021-12-29T15:20:11 | branch start, blah blah some progress | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index b1ae6869..85313fa0 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -2,6 +2,8 @@ use std::sync::atomic::{
AtomicUsize,
Ordering,
};
+use std::sync::Arc;
+
use std::{
alloc,
... | 1 | 27 | 1 |
53e6fe9ddb34af179071e88c96ca0d5b731e2f6c | Parker Timmerman | 2022-01-03T18:30:57 | get rid of commented out method | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index ade35350..b1ae6869 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -42,15 +42,6 @@ impl ArcString {
ArcString { len, ptr }
}
- // TODO: I imagine eventually this will be used... | 1 | 0 | 9 |
c8108382e171c03fec21bbee5da2abc95949641e | Parker Timmerman | 2021-12-29T15:39:24 | fix TODO, get rid of the ugly write_str(...) method | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 883cc595..ade35350 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -25,32 +25,32 @@ pub struct ArcString {
impl ArcString {
#[inline]
- pub fn with_capacity(capacity: usize) -> Self ... | 3 | 34 | 39 |
42fb9e3565efb73a3d1783b2e992262b2be5b45f | Parker Timmerman | 2021-12-27T18:33:13 | cargo fmt | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index abd80047..e0f62156 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -121,7 +121,6 @@ impl CompactStr {
///
/// # Panics
/// Panics if the new capacity overflows `usize`
- ///
#[inline]
pub fn reserve(&mut s... | 2 | 5 | 2 |
da5d3e5d299378fe3d5fdf21cc467df2e199590f | Parker Timmerman | 2021-12-27T18:31:35 | add benchmarks | diff --git a/compact_str/benches/apis.rs b/compact_str/benches/apis.rs
index 85a63a92..9bc5768f 100644
--- a/compact_str/benches/apis.rs
+++ b/compact_str/benches/apis.rs
@@ -42,6 +42,24 @@ fn compact_str_very_big_heap_length(c: &mut Criterion) {
});
}
+fn compact_str_reserve_small(c: &mut Criterion) {
+ c.b... | 1 | 42 | 2 |
17163d32dfeedc2aa532b47f3abd74465adf96d8 | Parker Timmerman | 2021-12-23T18:55:52 | branch start, some progress | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 0a787fef..331d7808 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -74,6 +74,11 @@ impl InlineString {
(self.metadata & !LEADING_BIT_MASK) as usize
}
+ #[inline]
+ pub const fn ca... | 1 | 5 | 0 |
2aa49ed941a8b7213537cffc0ae56c8a21c28455 | Parker Timmerman | 2021-12-23T19:45:27 | add is_empty method to silence clippy | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 2941544f..d2c3cc99 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -92,6 +92,11 @@ impl CompactStr {
self.repr.len()
}
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+
#[inli... | 1 | 5 | 0 |
448fe148a673387dc72679437588ba1270c33ef4 | Parker Timmerman | 2021-12-23T19:44:03 | unions in const fns are unstable on our MSRV | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 9e5e2830..c2efd469 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -93,13 +93,13 @@ impl Repr {
}
#[inline(always)]
- const fn discriminant(&self) -> Discriminant {
+ fn discriminant(&self) -> Di... | 1 | 2 | 2 |
4a3e070cec1c97932da543658a5f2dfb185b0b09 | Parker Timmerman | 2021-12-09T19:49:35 | rename ArcStr to ArcString | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 647f4092..d875a86f 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -18,35 +18,35 @@ use std::{
const MAX_REFCOUNT: usize = (isize::MAX) as usize;
#[repr(C)]
-pub struct ArcStr {
+pub struct... | 2 | 46 | 42 |
2a73787cf65521a84eb9100e97904b3f0b271be6 | Parker Timmerman | 2021-12-08T23:01:26 | super small two line move | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index b346c853..c2f29690 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -5,10 +5,11 @@ use static_assertions::{
const_assert_eq,
};
+mod iter;
+
mod discriminant;
mod heap;
mod inline;
-mod iter;
mod packed... | 1 | 2 | 1 |
5c79a6550e1948bba745a7bb00956ca3ac17ae60 | Parker Timmerman | 2021-12-08T22:40:08 | fix size assertions for 32-bit | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index af9f35c1..647f4092 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -231,5 +231,8 @@ mod test {
}
}
-static_assertions::const_assert_eq!(mem::size_of::<ArcStr>(), 16);
-static_assertions... | 1 | 5 | 2 |
a5cc1f04d0a77f7b4c845cc042e27e422f36e2f9 | Parker Timmerman | 2021-12-08T22:26:10 | more comments, more tests, clippy fixes | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 5248042c..ee6fa221 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -24,18 +24,6 @@ pub struct ArcStr {
}
impl ArcStr {
- #[inline]
- pub fn new() -> Self {
- let ptr = ArcStrIn... | 2 | 23 | 33 |
f340e77894fd012bbc0cc45177fd37655eb24446 | Parker Timmerman | 2021-12-08T22:14:45 | add a bunch of comments around SAFETY and more testing | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 132bf02a..5248042c 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -39,6 +39,9 @@ impl ArcStr {
#[inline]
pub fn as_str(&self) -> &str {
let buffer = self.inner().as_bytes();... | 1 | 81 | 23 |
b42965b0707af230f4734e72531a122d38a7075c | Parker Timmerman | 2021-12-08T17:30:56 | get rid of OffsetPointer, MVP new ArcStr | diff --git a/compact_str/src/repr/heap/arc.rs b/compact_str/src/repr/heap/arc.rs
index 67ffa15a..dbca0ee3 100644
--- a/compact_str/src/repr/heap/arc.rs
+++ b/compact_str/src/repr/heap/arc.rs
@@ -1,17 +1,17 @@
-use std::sync::atomic::Ordering;
+use std::sync::atomic::{
+ AtomicUsize,
+ Ordering,
+};
+
use std::{
... | 2 | 84 | 181 |
5fd724d9c230f243b29a7722c9c167f2491e5a41 | Parker Timmerman | 2021-12-08T16:39:35 | commenting out in-progress impl | diff --git a/compact_str/src/repr/heap/mod.rs b/compact_str/src/repr/heap/mod.rs
index 8503aafb..2e3fad0e 100644
--- a/compact_str/src/repr/heap/mod.rs
+++ b/compact_str/src/repr/heap/mod.rs
@@ -29,10 +29,11 @@ impl HeapString {
impl From<String> for HeapString {
fn from(s: String) -> Self {
- let paddin... | 1 | 4 | 3 |
5395a001f870a183eec0f363432246b060469b94 | Parker Timmerman | 2021-10-18T03:32:16 | some refactoring | diff --git a/compact_str/src/repr/arc.rs b/compact_str/src/repr/arc.rs
deleted file mode 100644
index 9c928ead..00000000
--- a/compact_str/src/repr/arc.rs
+++ /dev/null
@@ -1,216 +0,0 @@
-use std::alloc;
-use std::fmt;
-use std::mem;
-use std::ops::Deref;
-use std::ptr;
-use std::slice;
-use std::str;
-use std::sync::a... | 4 | 285 | 219 |
ef4ed34dbc10606b46ad185ea2f2fe2d690e6cdf | Parker Timmerman | 2021-10-18T01:42:37 | initial commit, MVP ArcStr | diff --git a/compact_str/src/repr/arc.rs b/compact_str/src/repr/arc.rs
new file mode 100644
index 00000000..9c928ead
--- /dev/null
+++ b/compact_str/src/repr/arc.rs
@@ -0,0 +1,216 @@
+use std::alloc;
+use std::fmt;
+use std::mem;
+use std::ops::Deref;
+use std::ptr;
+use std::slice;
+use std::str;
+use std::sync::atomi... | 3 | 223 | 7 |
2253c5d7b858249218adf13e3e358051e85f3f25 | Parker Timmerman | 2021-11-14T23:49:53 | initial commit, change version for serde example | diff --git a/examples/serde/Cargo.toml b/examples/serde/Cargo.toml
index 60bad349..da065510 100644
--- a/examples/serde/Cargo.toml
+++ b/examples/serde/Cargo.toml
@@ -6,6 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-compact... | 1 | 1 | 1 |
3260862ab3d40346d021fa00c06f776e5dc4bdd8 | Parker Timmerman | 2021-11-14T23:13:04 | update serde example again | diff --git a/examples/serde/Cargo.toml b/examples/serde/Cargo.toml
index 2e243140..60bad349 100644
--- a/examples/serde/Cargo.toml
+++ b/examples/serde/Cargo.toml
@@ -6,6 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-compact... | 1 | 1 | 1 |
a94042aae96a01df4c4d19150a0ef7a4b1a1ae13 | Parker Timmerman | 2021-11-14T23:05:42 | import version of CompactStr that can be built with edition 2018 | diff --git a/examples/serde/Cargo.toml b/examples/serde/Cargo.toml
index 60bad349..2e243140 100644
--- a/examples/serde/Cargo.toml
+++ b/examples/serde/Cargo.toml
@@ -6,6 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-compact... | 1 | 1 | 1 |
aa37c18f6d3a44df3d423480c796b3edad40bed0 | Parker Timmerman | 2021-11-14T22:20:47 | cargo fmt | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 465dbe72..02cc5740 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -237,5 +237,4 @@ impl FromIterator<String> for CompactStr {
}
}
-
static_assertions::assert_eq_size!(CompactStr, String);
diff --git a/compact_str/src/repr/i... | 2 | 2 | 2 |
2704b2b53cf60773f92dc3aabb6e1ccd55a3c10b | Parker Timmerman | 2021-11-14T22:11:47 | implement FromIterator on CompactStr, add proptests | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 002e399f..465dbe72 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -16,6 +16,7 @@ use core::{
cmp::Ordering,
fmt,
hash::{Hash, Hasher},
+ iter::FromIterator,
ops::Deref,
str::FromStr,
};
@@ -201,4 +202,40... | 3 | 73 | 4 |
1905a597fa229b957fdacd324012562ad28af433 | Parker Timmerman | 2021-11-14T21:54:35 | implement FromIterator for AsRef<str> types | diff --git a/compact_str/src/repr/iter.rs b/compact_str/src/repr/iter.rs
index 1e2e15da..aad37524 100644
--- a/compact_str/src/repr/iter.rs
+++ b/compact_str/src/repr/iter.rs
@@ -1,15 +1,7 @@
-//! Implementations of the `FromIterator` trait to make building `CompactStr`s easier
-
-use core::{
- iter::FromIterator,
-... | 1 | 101 | 14 |
9fb9851097d5af2a242621aa153c904477f4e820 | Parker Timmerman | 2021-11-14T21:28:12 | initial commit, implement FromIterator<char> for Repr | diff --git a/compact_str/src/repr/heap.rs b/compact_str/src/repr/heap.rs
index 60e979a6..a15e988e 100644
--- a/compact_str/src/repr/heap.rs
+++ b/compact_str/src/repr/heap.rs
@@ -21,4 +21,13 @@ impl HeapString {
}
}
+impl From<String> for HeapString {
+ fn from(s: String) -> Self {
+ let padding = PAD... | 4 | 113 | 0 |
f09aeadddf7f55bc215d5cd1b7b31784bdcf2e78 | Parker Timmerman | 2021-10-29T20:26:05 | initial commit, impl FromStr for CompactStr, and add test to confirm usability | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index ed5785f7..002e399f 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -17,6 +17,7 @@ use core::{
fmt,
hash::{Hash, Hasher},
ops::Deref,
+ str::FromStr,
};
mod repr;
@@ -181,6 +182,13 @@ impl<'a> From<&'a String> fo... | 2 | 19 | 0 |
7affa3f65094d18514782a6aa642b95cd3c7e266 | Parker Timmerman | 2021-10-22T21:06:20 | initial commit, make MSRV 1.56 and upgrade to edition 2021 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index ae45ed37..2639d714 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -3,7 +3,8 @@ name = "compact_str"
description = "A memory efficient immutable string type that transparently stores strings on the stack, when possible"
version = "... | 1 | 2 | 1 |
7ec521d2c1e29574dd77e09fef131a1b4a576616 | Ville Penttinen | 2021-09-23T16:05:01 | Add impl PartialEq<CompactStr> for &str | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 52e7f527..ed5785f7 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -139,6 +139,12 @@ impl PartialEq<CompactStr> for String {
}
}
+impl PartialEq<CompactStr> for &str {
+ fn eq(&self, other: &CompactStr) -> bool {
+ ... | 2 | 10 | 0 |
16128ca79968b554f9bde00e7990e90195c820b6 | Parker Timmerman | 2021-09-21T14:04:47 | add benchmark to time how long it takes to get a str ref | diff --git a/compact_str/benches/comparison.rs b/compact_str/benches/comparison.rs
index eab3c08e..0d2eb49e 100644
--- a/compact_str/benches/comparison.rs
+++ b/compact_str/benches/comparison.rs
@@ -68,10 +68,49 @@ fn cloning(c: &mut Criterion) {
group.bench_with_input(
BenchmarkId::new("std::Stri... | 1 | 41 | 2 |
9dfae4c0f8799e595048ff4fdbb0a84c5ced69be | Parker Timmerman | 2021-09-20T22:02:24 | remove pub visibility where it's not needed | diff --git a/compact_str/src/repr/heap.rs b/compact_str/src/repr/heap.rs
index 7edb27ae..60e979a6 100644
--- a/compact_str/src/repr/heap.rs
+++ b/compact_str/src/repr/heap.rs
@@ -8,7 +8,7 @@ const PADDING: [u8; PADDING_SIZE] = [HEAP_MASK; PADDING_SIZE];
#[repr(C)]
#[derive(Debug, Clone)]
pub struct HeapString {
- ... | 3 | 4 | 4 |
160ada865e9a17b0b216d711ced486ad0c3fcc45 | Parker Timmerman | 2021-09-20T21:57:32 | allow dead_code in serde example | diff --git a/examples/serde/src/main.rs b/examples/serde/src/main.rs
index 33f4b34a..d7bace2c 100644
--- a/examples/serde/src/main.rs
+++ b/examples/serde/src/main.rs
@@ -1,3 +1,6 @@
+// the fields in `Person` and `Address` are unread, hence the dead code warnings
+#![allow(dead_code)]
+
use compact_str::CompactStr;
... | 1 | 3 | 0 |
d4ea32549693a9cb2d3eef3f9053cbc12db45f37 | Aleksey Kladov | 2021-09-20T08:56:29 | missing rename | diff --git a/compact_str/src/serde.rs b/compact_str/src/serde.rs
index f65db5b8..a69c45bb 100644
--- a/compact_str/src/serde.rs
+++ b/compact_str/src/serde.rs
@@ -2,7 +2,7 @@ use super::CompactStr;
use serde::de::{Deserializer, Error, Unexpected, Visitor};
use std::fmt;
-fn smart_str<'de: 'a, 'a, D: Deserializer<'d... | 1 | 2 | 2 |
2d1b390c8a3bbbf02683115ead71618d81132f3b | Aleksey Kladov | 2021-09-20T08:45:53 | fix typo | diff --git a/compact_str/src/repr/discriminant.rs b/compact_str/src/repr/discriminant.rs
index 2f72c45d..2fad6d9f 100644
--- a/compact_str/src/repr/discriminant.rs
+++ b/compact_str/src/repr/discriminant.rs
@@ -17,7 +17,7 @@ pub struct DiscriminantMask {
impl DiscriminantMask {
#[inline]
- pub const fn disci... | 2 | 2 | 2 |
85fb12ed1c78aa7a7bf3bd0bd5ec04cbb35644e8 | Aleksey Kladov | 2021-09-20T08:36:42 | add missing repr(C)
We store `DiscriminantMask` in a union, so we need to repr-c it to
guarantee that type-punning works | diff --git a/compact_str/src/repr/discriminant.rs b/compact_str/src/repr/discriminant.rs
index 2f72c45d..6c3dc4d1 100644
--- a/compact_str/src/repr/discriminant.rs
+++ b/compact_str/src/repr/discriminant.rs
@@ -9,6 +9,7 @@ pub enum Discriminant {
Packed,
}
+#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ... | 1 | 1 | 0 |
189e592a994428d4bedebf0a3d2ebed7694d0553 | Aleksey Kladov | 2021-09-20T08:33:14 | add missing inline
The `Deref` one especially looks like it can be rather important | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index a40d8b3e..6b95b28d 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -98,6 +98,7 @@ impl CompactStr {
}
impl Default for CompactStr {
+ #[inline]
fn default() -> Self {
CompactStr::new("")
}
@@ -106,18 +107,21... | 1 | 4 | 0 |
8c6242ecda07083e39d7cf7793db54f724635d36 | Parker Timmerman | 2021-09-20T01:30:26 | update example to use version from crates.io | diff --git a/examples/serde/Cargo.toml b/examples/serde/Cargo.toml
index 14c4648e..60bad349 100644
--- a/examples/serde/Cargo.toml
+++ b/examples/serde/Cargo.toml
@@ -6,6 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-compact... | 1 | 1 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.