-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #988 from creusot-rs/string-specs
Basic specs for strings and str
- Loading branch information
Showing
57 changed files
with
342 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::*; | ||
use ::std::ops::Deref; | ||
|
||
extern_spec! { | ||
mod std { | ||
mod string { | ||
impl Deref for String { | ||
#[ensures(result@ == self@)] | ||
fn deref(&self) -> &str; | ||
} | ||
|
||
impl String { | ||
#[ensures(result@ == self@.len())] | ||
fn len(&self) -> usize; | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
extern_spec! { | ||
impl str { | ||
#[ensures(result@ == self@)] | ||
fn to_string(&self) -> String; | ||
|
||
#[requires(ix@ < self@.len())] | ||
#[ensures(result.0@.concat(result.1@) == self@)] | ||
#[ensures(result.0@.len() == ix@)] | ||
fn split_at(&self, ix : usize) -> (&str, &str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.