feat: add smartstring
This commit is contained in:
23
live-reload-rust/smartstring/Cargo.lock
generated
Normal file
23
live-reload-rust/smartstring/Cargo.lock
generated
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "smartstring"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"smartstring 0.2.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "smartstring"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5579edba9651e6b9ccf0d516c4457521a149dadeb77e88b03eb1ae3183fe180a"
|
||||||
|
dependencies = [
|
||||||
|
"static_assertions",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "static_assertions"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
10
live-reload-rust/smartstring/Cargo.toml
Normal file
10
live-reload-rust/smartstring/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "smartstring"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
smartstring = "*"
|
||||||
8
live-reload-rust/smartstring/README.md
Normal file
8
live-reload-rust/smartstring/README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
reference:
|
||||||
|
https://fasterthanli.me/articles/peeking-inside-a-rust-enum
|
||||||
|
|
||||||
|
PDF:
|
||||||
|
https://playsecurity.org/getdoc/3960_FF94A1BACA2F799268DB484102E074D0/Peeking%20inside%20a%20Rust%20enum.pdf
|
||||||
|
|
||||||
|
|
||||||
11
live-reload-rust/smartstring/src/main.rs
Normal file
11
live-reload-rust/smartstring/src/main.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use smartstring::{Compact, SmartString};
|
||||||
|
use std::mem::size_of_val;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let smart = SmartString::<Compact>::from("hello world");
|
||||||
|
dbg!(size_of_val(&smart));
|
||||||
|
|
||||||
|
let stand = String::from("hello world");
|
||||||
|
dbg!(size_of_val(&stand));
|
||||||
|
dbg!(size_of_val(&stand) + stand.capacity());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user