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§

source

exec fn unicode_len(&self) -> usize

source

exec fn get_char(&self, i: usize) -> char

source

exec fn substring_ascii<'a>(&'a self, from: usize, to: usize) -> &'a str

source

exec fn substring_char<'a>(&'a self, from: usize, to: usize) -> &'a str

source

exec fn get_ascii(&self, i: usize) -> u8

source

exec fn as_bytes_vec(&self) -> Vec<u8>

source

fn from_rust_str<'a>(&'a self) -> &'a str

👎Deprecated: from_rust_str is no longer necessary
source

fn into_rust_str<'a>(&'a self) -> &'a str

👎Deprecated: into_rust_str is no longer necessary

Implementations on Foreign Types§

source§

impl StrSliceExecFns for str

source§

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

requires
i < self@.len(),
ensures
self@.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

requires
self.is_ascii(),
from < self@.len(),
to <= self@.len(),
ensures
ret@ == 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

requires
from < self@.len(),
to <= self@.len(),
ensures
ret@ == self@.subrange(from as int, to as int),
ret.is_ascii() == self.is_ascii(),
source§

exec fn get_ascii(&self, i: usize) -> b : u8

requires
self.is_ascii(),
ensures
self.view().index(i as int) as u8 == b,
source§

exec fn as_bytes_vec(&self) -> ret : Vec<u8>

requires
self.is_ascii(),
ensures
ret.view() == Seq::new(self.view().len(), |i| self.view().index(i) as u8),
source§

exec fn from_rust_str<'a>(&'a self) -> &'a str

👎Deprecated: from_rust_str is no longer necessary
source§

exec fn into_rust_str<'a>(&'a self) -> &'a str

👎Deprecated: into_rust_str is no longer necessary

Implementors§