devtools helpers extended (#1186)

* devtools extensions

* some doc effort
This commit is contained in:
Nikolay Volf
2016-06-02 11:51:03 +02:00
committed by Gav Wood
parent 8596a347ea
commit 7ad9c73c75
3 changed files with 58 additions and 1 deletions

View File

@@ -26,7 +26,11 @@ pub struct RandomTempPath {
}
pub fn random_filename() -> String {
(0..8).map(|_| ((random::<f32>() * 26.0) as u8 + 97) as char).collect()
random_str(8)
}
pub fn random_str(len: usize) -> String {
(0..len).map(|_| ((random::<f32>() * 26.0) as u8 + 97) as char).collect()
}
impl RandomTempPath {
@@ -54,6 +58,12 @@ impl RandomTempPath {
pub fn as_str(&self) -> &str {
self.path.to_str().unwrap()
}
pub fn new_in(&self, name: &str) -> String {
let mut path = self.path.clone();
path.push(name);
path.to_str().unwrap().to_owned()
}
}
impl Drop for RandomTempPath {