Accept non-\n line endings

On Windows, include_str brings in cxxbridge.h with \r\n line endings.
This commit is contained in:
David Tolnay 2020-02-24 02:01:47 -08:00
parent bce77ba9fe
commit 2a1eaac049
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1,8 +1,8 @@
pub static HEADER: &str = include_str!("include/cxxbridge.h");
pub fn get(guard: &str) -> &'static str {
let ifndef = format!("#ifndef {}\n", guard);
let endif = format!("#endif // {}\n", guard);
let ifndef = format!("#ifndef {}", guard);
let endif = format!("#endif // {}", guard);
let begin = HEADER.find(&ifndef);
let end = HEADER.find(&endif);
if let (Some(begin), Some(end)) = (begin, end) {