fn first_word(s: String) -> &str { s.split(' ').next().unwrap() } The compiler says the borrowed value does not live long enough. I just want the first word.
I have a loop that sums every element of a large std::vector<int> that is at least 128. If I sort the vector first (outside the timed region), the loop runs about five times faster: #include <algorithm> #include <chrono> #include <iostream> #include <random> #include <vector> int main() { std::vecto