From 7df83030e57e3a1a565bba0208e322f140d5dfe1 Mon Sep 17 00:00:00 2001 From: Al Liu Date: Sun, 15 Sep 2024 19:42:12 +0800 Subject: [PATCH] Add document for memory size (#20) --- README.md | 2 ++ src/lib.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index a685fb2..521e198 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Therefore, we have created the `FastStr` type. By sacrificing immutability, we c `FastStr` implements `From` trait for various types, so you can easily migrate to `FastStr` by replacing `String` with `FastStr` and adding `.into()`. + **Note:** The memory size of `FastStr` is not `24`, so switching from `String` or [`SmolStr`](https://docs.rs/smol_str/latest/smol_str/struct.SmolStr.html) to `FastStr` may not be harmless. + For example, if your API is something like this: ```rust diff --git a/src/lib.rs b/src/lib.rs index d064c25..5e5c940 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,8 @@ use core::{ use simdutf8::basic::{from_utf8, Utf8Error}; /// `FastStr` is a string type that try to avoid the cost of clone. +/// +/// **Note:** The memory size of `FastStr` is not `24`, so switching from [`String`] or [`SmolStr`](https://docs.rs/smol_str/latest/smol_str/struct.SmolStr.html) to `FastStr` may not be harmless. #[derive(Clone)] pub struct FastStr(Repr);