3 ms·
Actually I sort of knew all that (though it was the first time I'd seen lazy_static! and had to infer it from context). The question was more about "why"? Aga
by ajross 8y ago
Actually I sort of knew all that (though it was the first time I'd seen lazy_static! and had to infer it from context).
The question was more about "why"? Again in C the equivalent is literally a string literal. There's really no easier way to express "double newline" in Rust than this thing which requires that the reader parse a "lazy static", a parametrized type, an explicit type conversion and a library utility? Why not?
- est31 8y agoThis thing is so bulky because the API that TwoWaySearcher has is so bulky. You could also have a very simple API that just takes a string literal. It's less a problem of Rust and more of that TwoWaySearcher struct.
- coldtea 8y ago>There's really no easier way to express "double newline" in Rust than this thing which requires that the reader parse a "lazy static", a parametrized type, an explicit type conversion and a library utility? Why not? The code doesn't express 'double newline'. That would be just the "\r\n\r\n".as_bytes() The code lazily initializes an TwoWaySearcher to parse such double newlines.
- steveklabnik 8y agoAlso note that b”” is nicer than .as_bytes()