when you use dyn trait object, currently you cannot add multiply trait bound for the trait object like

    1. fn foo(_: Box<dyn Iterator<Item=()> + Debug>) {
    2. }

    if you really want multiply trait bound, you can define a new trait

    1. trait IteratorAndDebug: Iterator<Item=()> + Debug
    2. fn foo(_: Box<dyn IteratorAndDebug>) {}

    But auto trait is an exception, you can add Sync and Send for dyn trait object and this is allowed

    1. fn foo(_: Box<dyn Iterator<Item=()> + Sync + Send>) {
    2. }
    1. send_sync git:(master) cargo check
    2. Checking send_sync v0.1.0 (/home/sean/data/code/github.com/xujihui1985/learningrust/send_sync)
    3. error[E0225]: only auto traits can be used as additional traits in a trait object
    4. --> src/main.rs:52:39
    5. |
    6. 52 | fn foo(_: Box<dyn Iterator<Item=()> + std::fmt::Debug>) {
    7. | ----------------- ^^^^^^^^^^^^^^^ additional non-auto trait
    8. | |
    9. | first non-auto trait
    10. |
    11. = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Iterator + Debug {}`
    12. = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
    13. For more information about this error, try `rustc --explain E0225`.
    14. error: could not compile `send_sync` due to previous error