Type Definition no_std_strings::str256

source ·
pub type str256 = tstr<256>;
Expand description

Each type strN is represented underneath by a [u8;N] with N<=256. The first byte of the array always holds the length of the string. Each such type can hold a string of up to N-1 bytes, with max size=255.
In addition, the str4-str128 types implement core::ops::Add, allowing for string concatenation of strings of the same type. For example, two str8 strings will always concatenate to str16, and similarly for all other strN types up to str128.

  use no_std_strings::str8;
  let c1 = str8::from("abcd");
  let c2 = str8::from("xyz");
  let c3 = c1 + c2;
  assert_eq!(c3,"abcdxyz");
  assert_eq!(c3.capacity(),15);