3 releases (breaking)

0.3.0 Jun 13, 2022
0.2.0 Apr 27, 2022
0.1.1 Apr 27, 2022
0.1.0 Mar 5, 2022

#1366 in Rust patterns

Download history 12/week @ 2022-12-01 9/week @ 2022-12-08 16/week @ 2022-12-15 9/week @ 2022-12-22 11/week @ 2022-12-29 30/week @ 2023-01-05 17/week @ 2023-01-12 32/week @ 2023-01-19 48/week @ 2023-01-26 61/week @ 2023-02-02 58/week @ 2023-02-09 48/week @ 2023-02-16 52/week @ 2023-02-23 5/week @ 2023-03-02 34/week @ 2023-03-09 33/week @ 2023-03-16

135 downloads per month

MIT license

19KB
448 lines

astr

array string

A const lenght stack str

Unsized Const Length Dynamic
[T] (slice) [T; LEN] (array) Vec<T>
str AStr<LEN> String

Example

use astr::{AStr, astr};
// use the macro to infer the length of the string
let s = astr!("Hello World!");
assert_eq!(s, "Hello World!");

// also works in const context
const S1: &'static AStr<12> = astr!("Hello World!");
// the type is also copy and sized so you can derefernce it
const S2: AStr<12> = *astr!("Hello World!");
assert_eq!(S1, S2);

// use try_from to convert a String
let source_string = String::from("Hello World!");
let s2 = AStr::<12>::try_from(source_string).unwrap();
assert_eq!(s2, "Hello World!");

Dependencies

~63KB