Skip to content

Commit

Permalink
feat: add string
Browse files Browse the repository at this point in the history
  • Loading branch information
katopz committed Sep 27, 2023
1 parent 459c184 commit 5770986
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/rust/r1/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ let s1 = String::from("Hello ");
| +----------------------------------------------+|
+--------------------------------------------------+
```

> 🤔 [refer to Swatinem](https://swatinem.de/blog/optimized-strings/)
| Name | Size of `<T>` | Size of `<Option<T>>` | Clone | SSO | Mutable |
| ------------- | ------------: | --------------------: | ----- | ------- | ------- |
| String | 24 | 24 | O(n) | - | yes |
| Arc<str> | 16 | 16 | O(1) | - | no |
| arcstr | 8 | 8 | O(1) | - | no |
| smol_str | 24 | 24 | O(1) | 23 | no |
| kstring (arc) | 24 | 32 | O(1) | 15 / 22 | no |
| flexstr | 24 | 32 | O(1) | 22 | no |
| compact_str | 24 | 24 | O(n) | 24 | yes |
| smartstring | 24 | 32 | O(n) | 23 | yes |

0 comments on commit 5770986

Please sign in to comment.