If this is a worth-while optimization (which I think it is), then why not move it directly into `find` ? This way, every one will benefit from it, and callers will have that much less to worry about. Then you can change the entire section to just `haystack = find!pred(haystack, needle);`

Speaking of pred: you did not take it into account: This optimization is only valid if pred is `"a == b"`.