aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-11-01 21:55:00 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-11-01 21:55:00 +0100
commit7d2be237297c16628cb3d58774e808cac9c92fc1 (patch)
tree55cb240828bac9968f94166e740b567b66928e3b /src/utils.rs
parent2932d67d87fa2ff41fcdf46ce269ba5b49294930 (diff)
downloadmail-7d2be237297c16628cb3d58774e808cac9c92fc1.tar.gz
improve lifetime management with supercow
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 5db8957..5cce04d 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,16 +1,5 @@
-use std::{
- ffi,
- str,
-};
use libc;
-
-pub trait FromPtr<T> {
- fn from_ptr(ptr: T) -> Self;
-}
-
-// pub trait NewFromPtr<T, P> {
-// fn new(ptr: T, parent: Rc<P>) -> Self;
-// }
+use std::{ffi, str};
pub trait ToStr {
fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error>;
@@ -18,9 +7,7 @@ pub trait ToStr {
impl ToStr for *const libc::c_char {
fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error> {
- str::from_utf8(unsafe {
- ffi::CStr::from_ptr(*self)
- }.to_bytes())
+ str::from_utf8(unsafe { ffi::CStr::from_ptr(*self) }.to_bytes())
}
}
@@ -30,13 +17,13 @@ pub trait ToString {
impl ToString for *const libc::c_char {
fn to_string(&self) -> String {
- unsafe {
- ffi::CStr::from_ptr(*self).to_string_lossy().into_owned()
- }
+ unsafe { ffi::CStr::from_ptr(*self).to_string_lossy().into_owned() }
}
}
-
-pub struct Owner;
-
-
+/// A streaming iterator, as found in https://github.com/emk/rust-streaming
+pub trait StreamingIterator<'a, T> {
+ /// Return either the next item in the sequence, or `None` if all items
+ /// have been consumed.
+ fn next(&'a mut self) -> Option<T>;
+}