From c3cbc20afbd7d33cbdc6631e31474e6aabc07e7c Mon Sep 17 00:00:00 2001 From: Pantonshire Date: Sun, 15 May 2022 18:30:10 +0100 Subject: [PATCH] Mention upper bound of const parameter N in ShString documentation --- src/strings.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/strings.rs b/src/strings.rs index 4d66276..df5aa63 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -33,7 +33,12 @@ pub type ShString22 = ShString<22>; /// A non-growable string which may be allocated either on the stack or on the heap; strings `N` /// bytes or shorter will be allocated on the stack, while strings longer than `N` bytes will be -/// allocated on the heap. +/// allocated on the heap. Intended to be used when lots of small strings need to be stored, and +/// these strings do not need to grow. +/// +/// `N` must be less than or equal to `u8::MAX`. Exceeding this limit will cause a compile-time +/// error. Clearly it be better for `N` to be a `u8` rather than a `usize`, but this is +/// unfortunately not possible due to limitations of const generics. #[derive(Clone)] pub struct ShString(Repr);