Type Alias json_syntax::object::Key

source ·
pub type Key = SmallString<[u8; 16]>;
Expand description

Object key.

Aliased Type§

struct Key { /* private fields */ }

Implementations

source§

impl<A> SmallString<A>
where A: Array<Item = u8>,

source

pub fn new() -> SmallString<A>

Construct an empty string.

source

pub fn with_capacity(n: usize) -> SmallString<A>

Construct an empty string with enough capacity pre-allocated to store at least n bytes.

Will create a heap allocation only if n is larger than the inline capacity.

source

pub fn from_str(s: &str) -> SmallString<A>

Construct a SmallString by copying data from a &str.

source

pub fn from_string(s: String) -> SmallString<A>

Construct a SmallString by using an existing allocation.

source

pub fn from_buf(buf: A) -> Result<SmallString<A>, FromUtf8Error<A>>

Constructs a new SmallString on the stack using UTF-8 bytes.

If the provided byte array is not valid UTF-8, an error is returned.

source

pub unsafe fn from_buf_unchecked(buf: A) -> SmallString<A>

Constructs a new SmallString on the stack using the provided byte array without checking that the array contains valid UTF-8.

§Safety

This function is unsafe because it does not check that the bytes passed to it are valid UTF-8. If this constraint is violated, it may cause memory unsafety issues, as the Rust standard library functions assume that &strs are valid UTF-8.

source

pub fn inline_size(&self) -> usize

The maximum number of bytes this string can hold inline.

source

pub fn len(&self) -> usize

Returns the length of this string, in bytes.

source

pub fn is_empty(&self) -> bool

Returns true if this string is empty.

source

pub fn capacity(&self) -> usize

Returns the number of bytes this string can hold without reallocating.

source

pub fn spilled(&self) -> bool

Returns true if the data has spilled into a separate heap-allocated buffer.

source

pub fn drain(&mut self) -> Drain<'_>

Empties the string and returns an iterator over its former contents.

source

pub fn push(&mut self, ch: char)

Appends the given char to the end of this string.

§Examples
use smallstr::SmallString;

let mut s: SmallString<[u8; 8]> = SmallString::from("foo");

s.push('x');

assert_eq!(s, "foox");
source

pub fn push_str(&mut self, s: &str)

Appends the given string slice to the end of this string.

§Examples
use smallstr::SmallString;

let mut s: SmallString<[u8; 8]> = SmallString::from("foo");

s.push_str("bar");

assert_eq!(s, "foobar");
source

pub fn pop(&mut self) -> Option<char>

Removes the last character from this string and returns it.

Returns None if the string is empty.

source

pub fn grow(&mut self, new_cap: usize)

Reallocates to set the new capacity to new_cap.

§Panics

If new_cap is less than the current length.

source

pub fn reserve(&mut self, additional: usize)

Ensures that this string’s capacity is at least additional bytes larger than its length.

The capacity may be increased by more than additional bytes in order to prevent frequent reallocations.

source

pub fn reserve_exact(&mut self, additional: usize)

Ensures that this string’s capacity is additional bytes larger than its length.

source

pub fn shrink_to_fit(&mut self)

Shrink the capacity of the string as much as possible.

When possible, this will move the data from an external heap buffer to the string’s inline storage.

source

pub fn truncate(&mut self, len: usize)

Shorten the string, keeping the first len bytes.

This does not reallocate. If you want to shrink the string’s capacity, use shrink_to_fit after truncating.

§Panics

If len does not lie on a char boundary.

source

pub fn as_str(&self) -> &str

Extracts a string slice containing the entire string.

source

pub fn as_mut_str(&mut self) -> &mut str

Extracts a string slice containing the entire string.

source

pub fn clear(&mut self)

Removes all contents of the string.

source

pub fn remove(&mut self, idx: usize) -> char

Removes a char from this string at a byte position and returns it.

§Panics

If idx does not lie on a char boundary.

source

pub fn insert(&mut self, idx: usize, ch: char)

Inserts a char into this string at the given byte position.

§Panics

If idx does not lie on char boundaries.

source

pub fn insert_str(&mut self, idx: usize, s: &str)

Inserts a &str into this string at the given byte position.

§Panics

If idx does not lie on char boundaries.

source

pub unsafe fn as_mut_vec(&mut self) -> &mut SmallVec<A>

Returns a mutable reference to the contents of the SmallString.

§Safety

This function is unsafe because it does not check that the bytes passed to it are valid UTF-8. If this constraint is violated, it may cause memory unsafety issues, as the Rust standard library functions assume that &strs are valid UTF-8.

source

pub fn into_string(self) -> String

Converts the SmallString into a String, without reallocating if the SmallString has already spilled onto the heap.

source

pub fn into_boxed_str(self) -> Box<str>

Converts the SmallString into a Box<str>, without reallocating if the SmallString has already spilled onto the heap.

Note that this will drop excess capacity.

source

pub fn into_inner(self) -> Result<A, SmallString<A>>

Convert the SmallString into A, if possible. Otherwise, return Err(self).

This method returns Err(self) if the SmallString is too short (and the A contains uninitialized elements) or if the SmallString is too long (and the elements have been spilled to the heap).

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(char) -> bool,

Retains only the characters specified by the predicate.

In other words, removes all characters c such that f(c) returns false. This method operates in place and preserves the order of retained characters.

§Examples
use smallstr::SmallString;

let mut s: SmallString<[u8; 16]> = SmallString::from("f_o_ob_ar");

s.retain(|c| c != '_');

assert_eq!(s, "foobar");

Trait Implementations

source§

impl<A> Write for SmallString<A>
where A: Array<Item = u8>,

source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
source§

fn write_char(&mut self, ch: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

impl<A> Deref for SmallString<A>
where A: Array<Item = u8>,

§

type Target = str

The resulting type after dereferencing.
source§

fn deref(&self) -> &str

Dereferences the value.
source§

impl<A> Default for SmallString<A>
where A: Default + Array<Item = u8>,

source§

fn default() -> SmallString<A>

Returns the “default value” for a type. Read more
source§

impl<'a, A> PartialEq<str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn eq(&self, rhs: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, rhs: &str) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A> PartialEq<&'a str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn eq(&self, rhs: &&'a str) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, rhs: &&'a str) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A, B> PartialEq<SmallString<B>> for SmallString<A>
where A: Array<Item = u8>, B: Array<Item = u8>,

source§

fn eq(&self, rhs: &SmallString<B>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, rhs: &SmallString<B>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A> PartialEq<String> for SmallString<A>
where A: Array<Item = u8>,

source§

fn eq(&self, rhs: &String) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, rhs: &String) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A> PartialEq<Cow<'a, str>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn eq(&self, rhs: &Cow<'a, str>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, rhs: &Cow<'a, str>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A> IndexMut<Range<usize>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn index_mut(&mut self, index: Range<usize>) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<A> IndexMut<RangeTo<usize>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn index_mut(&mut self, index: RangeTo<usize>) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<A> IndexMut<RangeFull> for SmallString<A>
where A: Array<Item = u8>,

source§

fn index_mut(&mut self, index: RangeFull) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<A> IndexMut<RangeFrom<usize>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn index_mut(&mut self, index: RangeFrom<usize>) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<A> Debug for SmallString<A>
where A: Array<Item = u8>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<A> Borrow<str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl<A> Borrow<[u8]> for SmallString<A>
where A: Array<Item = u8>,

source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
source§

impl<A> From<char> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from(ch: char) -> SmallString<A>

Converts to this type from the input type.
source§

impl<A> From<Box<str>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from(s: Box<str>) -> SmallString<A>

Converts to this type from the input type.
source§

impl<'a, A> From<&'a str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from(s: &str) -> SmallString<A>

Converts to this type from the input type.
source§

impl<A> From<String> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from(s: String) -> SmallString<A>

Converts to this type from the input type.
source§

impl<A> Display for SmallString<A>
where A: Array<Item = u8>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<A> Hash for SmallString<A>
where A: Array<Item = u8>,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<A> PartialOrd for SmallString<A>
where A: Array<Item = u8>,

source§

fn partial_cmp(&self, rhs: &SmallString<A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<A> AsMut<str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn as_mut(&mut self) -> &mut str

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<A> AsRef<str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A> AsRef<[u8]> for SmallString<A>
where A: Array<Item = u8>,

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A> Extend<char> for SmallString<A>
where A: Array<Item = u8>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = char>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<A> Extend<String> for SmallString<A>
where A: Array<Item = u8>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = String>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, A> Extend<&'a str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a str>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, A> Extend<Cow<'a, str>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = Cow<'a, str>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, A> Extend<&'a char> for SmallString<A>
where A: Array<Item = u8>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a char>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<A> BorrowMut<str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn borrow_mut(&mut self) -> &mut str

Mutably borrows from an owned value. Read more
source§

impl<A> Clone for SmallString<A>
where A: Clone + Array<Item = u8>,

source§

fn clone(&self) -> SmallString<A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A> Index<RangeTo<usize>> for SmallString<A>
where A: Array<Item = u8>,

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: RangeTo<usize>) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl<A> Index<RangeFrom<usize>> for SmallString<A>
where A: Array<Item = u8>,

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: RangeFrom<usize>) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl<A> Index<Range<usize>> for SmallString<A>
where A: Array<Item = u8>,

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: Range<usize>) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl<A> Index<RangeFull> for SmallString<A>
where A: Array<Item = u8>,

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: RangeFull) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl<A> FromIterator<char> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from_iter<I>(iter: I) -> SmallString<A>
where I: IntoIterator<Item = char>,

Creates a value from an iterator. Read more
source§

impl<'a, A> FromIterator<&'a char> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from_iter<I>(iter: I) -> SmallString<A>
where I: IntoIterator<Item = &'a char>,

Creates a value from an iterator. Read more
source§

impl<'a, A> FromIterator<Cow<'a, str>> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from_iter<I>(iter: I) -> SmallString<A>
where I: IntoIterator<Item = Cow<'a, str>>,

Creates a value from an iterator. Read more
source§

impl<A> FromIterator<String> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from_iter<I>(iter: I) -> SmallString<A>
where I: IntoIterator<Item = String>,

Creates a value from an iterator. Read more
source§

impl<'a, A> FromIterator<&'a str> for SmallString<A>
where A: Array<Item = u8>,

source§

fn from_iter<I>(iter: I) -> SmallString<A>
where I: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
source§

impl<A> DerefMut for SmallString<A>
where A: Array<Item = u8>,

source§

fn deref_mut(&mut self) -> &mut str

Mutably dereferences the value.
source§

impl<A> Eq for SmallString<A>
where A: Array<Item = u8>,

source§

impl<A> Ord for SmallString<A>
where A: Array<Item = u8>,

source§

fn cmp(&self, rhs: &SmallString<A>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<A: Array<Item = u8>> Parse for SmallString<A>

source§

fn parse_in<C, E>( parser: &mut Parser<C, E>, _context: Context ) -> Result<Meta<Self, usize>, Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

source§

fn parse_str(content: &str) -> Result<(Self, CodeMap), Error>

source§

fn parse_str_with( content: &str, options: Options ) -> Result<(Self, CodeMap), Error>

source§

fn parse_infallible_utf8<C>(chars: C) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = char>,

source§

fn parse_utf8_infallible_with<C>( chars: C, options: Options ) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = char>,

source§

fn parse_utf8<C, E>(chars: C) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<char, E>>,

source§

fn parse_utf8_with<C, E>( chars: C, options: Options ) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<char, E>>,

source§

fn parse_infallible<C>(chars: C) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = DecodedChar>,

source§

fn parse_infallible_with<C>( chars: C, options: Options ) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = DecodedChar>,

source§

fn parse<C, E>(chars: C) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

source§

fn parse_with<C, E>( chars: C, options: Options ) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,