6 releases (breaking)

Uses old Rust 2015

0.4.0 Oct 15, 2016
0.3.0 Oct 13, 2016
0.2.1 Oct 13, 2016
0.1.0 Oct 12, 2016
0.0.0 Oct 7, 2016

#6 in #pascal

MIT license

43KB
1K SLoC

Pascal strings in Rust.

A PascalString, or ShortString is a String which stores its data on the stack. Because of this, it has a fixed maximum size, which cannot be changed. Traditionally, the size of a PascalString is 256 bytes - the first byte stores the length, which means that each remaining byte is indexable using only that byte.

This is a very niche string type - generally, you are better off using std::string::String, or the AsciiString type from the ascii crate if you need an ascii string. They have no upper size limit, and are cheaper to pass around as they are only 64 bytes on the stack. Generally, you should only use PascalString if:

  • You know that you absolutely, certainly cannot do without heap allocation.
  • You need to store your string data inline into your struct type - for example if you will allocate a bunch of these custom struct types into a pool allocator, and cannot afford the heap fragmentation.
  • You will keep, allocate, and deallocate a lot of short strings in your program.

Dependencies

~145KB