All is in the documentation. You can provide one of:
- A
&str
, - A
char
, - A closure,
Those three types implement the Pattern
trait. You are giving a String
to split
instead of a &str
.
Example:
fn main() {
let x = "".to_string();
let split = x.split("");
}
More Related Contents:
- Traits and Rust
- Why do try!() and ? not compile when used in a function that doesn’t return Option or Result?
- Why does linking lifetimes matter only with mutable references?
- Why is adding a lifetime to a trait with the plus operator (Iterator + ‘a) needed?
- How do I collect into an array?
- Cannot borrow as mutable more than once at a time in one code – but can in another very similar
- Is it considered a bad practice to implement Deref for newtypes?
- Implementing a trait for multiple types at once
- How do I get an owned value out of a `Box`?
- How can I store a Chars iterator in the same struct as the String it is iterating on?
- Converting from Option to Option
- How to disable unused code warnings in Rust?
- How do you use parent module imports in Rust?
- Why is the `Sized` bound necessary in this trait?
- How do I overcome match arms with incompatible types for structs implementing same trait?
- Example of how to use Conditional Compilation Macros in Rust
- How to take ownership of T from Arc?
- Is there any trait that specifies numeric functionality?
- Why would I use divergent functions?
- How to generate statically linked executables?
- What is the prelude?
- How to embed resources in Rust executable?
- Sized is not implemented for the type Fn
- Extend lifetime of variable
- How do I specify that a struct field must implement a trait?
- What does Rust’s unary || (parallel pipe) mean?
- How to create and write to memory mapped files?
- Downcast traits inside Rc for AST manipulation
- How to check in Rust if architecture is 32 or 64 bit?
- Is there any way to restrict a generic type to one of several types?