chris-morgan / rust-http

Completely OBSOLETE Rust HTTP library (server and client)
Other
390 stars 110 forks source link

Failed to compile with latest rust #190

Closed kstep closed 9 years ago

kstep commented 9 years ago
 — ~/git/rust-http master pts/3: cargo build                                                                                                                  
   Compiling http v0.1.0-pre (file:///home/kstep/git/rust-http)
src/http/headers/serialization_utils.rs:59:5: 59:31 error: mismatched types: expected `core::iter::Map<&'a str, &'a str, core::str::CharSplits<'a, char>, fn(&str) -> &str>`, found `core::iter::Map<&str, &str, core::str::CharSplits<'_, char>, fn(&str) -> &str {headers::serialization_utils::comma_split_iter::trim}>` (expected fn pointer, found fn item)
src/http/headers/serialization_utils.rs:59     value.split(',').map(trim)
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `http`.
To learn more, run the command again with --verbose.
kstep commented 9 years ago

Fixed by typecasting trim to fn(&str) -> &str explicitly:

diff --git a/src/http/headers/serialization_utils.rs b/src/http/headers/serialization_utils.rs
index 3f18873..3dfec59 100644
--- a/src/http/headers/serialization_utils.rs
+++ b/src/http/headers/serialization_utils.rs
@@ -56,7 +56,7 @@ pub fn comma_split_iter<'a>(value: &'a str)
         -> ::std::iter::Map<&'a str, &'a str, ::std::str::CharSplits<'a, char>, fn(&str) -> &str> {
     fn trim(w: &str) -> &str {w.trim_left()}

-    value.split(',').map(trim)
+    value.split(',').map(trim as fn(&str) -> &str)
 }

 pub trait WriterUtil: Writer {
kstep commented 9 years ago

See also https://github.com/rust-lang/rust/issues/20178.