Trait vstd::string::StrSliceExecFns
source · pub trait StrSliceExecFns {
// Required methods
exec fn unicode_len(&self) -> usize;
exec fn get_char(&self, i: usize) -> char;
exec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> &'a str;
exec fn substring_char<'a>(&'a self, from: usize, to: usize) -> &'a str;
exec fn get_ascii(&self, i: usize) -> u8;
exec fn as_bytes_vec(&self) -> Vec<u8>;
exec fn from_rust_str<'a>(&'a self) -> &'a str;
exec fn into_rust_str<'a>(&'a self) -> &'a str;
}
Required Methods§
sourceexec fn unicode_len(&self) -> usize
exec fn unicode_len(&self) -> usize
sourceexec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> &'a str
exec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> &'a str
sourceexec fn substring_char<'a>(&'a self, from: usize, to: usize) -> &'a str
exec fn substring_char<'a>(&'a self, from: usize, to: usize) -> &'a str
sourceexec fn as_bytes_vec(&self) -> Vec<u8>
exec fn as_bytes_vec(&self) -> Vec<u8>
Implementations on Foreign Types§
source§impl StrSliceExecFns for str
impl StrSliceExecFns for str
source§exec fn unicode_len(&self) -> l : usize
exec fn unicode_len(&self) -> l : usize
ensures
l as nat == self@.len(),
The len() function in rust returns the byte length. It is more useful to talk about the length of characters and therefore this function was added. Please note that this function counts the unicode variation selectors as characters. Warning: O(n)
source§exec fn get_char(&self, i: usize) -> c : char
exec fn get_char(&self, i: usize) -> c : char
requires
i < self@.len(),
ensuresself@.index(i as int) == c,
self.is_ascii() ==> forall |i: int| i < self@.len() ==> (self@.index(i) as nat) < 256,
Warning: O(n) not O(1) due to unicode decoding needed
source§exec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> ret : &'a str
exec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> ret : &'a str
requires
self.is_ascii(),
from < self@.len(),
to <= self@.len(),
ensuresret@ == self@.subrange(from as int, to as int),
ret.is_ascii() == self.is_ascii(),
source§exec fn substring_char<'a>(&'a self, from: usize, to: usize) -> ret : &'a str
exec fn substring_char<'a>(&'a self, from: usize, to: usize) -> ret : &'a str
requires
from < self@.len(),
to <= self@.len(),
ensuresret@ == self@.subrange(from as int, to as int),
ret.is_ascii() == self.is_ascii(),
source§exec fn get_ascii(&self, i: usize) -> b : u8
exec fn get_ascii(&self, i: usize) -> b : u8
requires
self.is_ascii(),
ensuresself.view().index(i as int) as u8 == b,
source§exec fn as_bytes_vec(&self) -> ret : Vec<u8>
exec fn as_bytes_vec(&self) -> ret : Vec<u8>
requires
self.is_ascii(),
ensuresret.view() == Seq::new(self.view().len(), |i| self.view().index(i) as u8),