/src/test/rustdoc/where.rs

https://gitlab.com/alx741/rust · Rust · 48 lines · 14 code · 10 blank · 24 comment · 2 complexity · 64987152e0d14185dac7bf466234f154 MD5 · raw file

  1. // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. #![crate_name = "foo"]
  11. pub trait MyTrait { fn dummy(&self) { } }
  12. // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A> where A: MyTrait"
  13. pub struct Alpha<A>(A) where A: MyTrait;
  14. // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait"
  15. pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); }
  16. // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait"
  17. pub fn charlie<C>() where C: MyTrait {}
  18. pub struct Delta<D>(D);
  19. // @has foo/struct.Delta.html '//*[@class="impl"]//code' \
  20. // "impl<D> Delta<D> where D: MyTrait"
  21. impl<D> Delta<D> where D: MyTrait {
  22. pub fn delta() {}
  23. }
  24. pub struct Echo<E>(E);
  25. // @has foo/struct.Echo.html '//*[@class="impl"]//code' \
  26. // "impl<E> MyTrait for Echo<E> where E: MyTrait"
  27. // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
  28. // "impl<E> MyTrait for Echo<E> where E: MyTrait"
  29. impl<E> MyTrait for Echo<E> where E: MyTrait {}
  30. pub enum Foxtrot<F> { Foxtrot1(F) }
  31. // @has foo/enum.Foxtrot.html '//*[@class="impl"]//code' \
  32. // "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
  33. // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
  34. // "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
  35. impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}
  36. // @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
  37. // "type Golf<T> where T: Clone = (T, T)"
  38. pub type Golf<T> where T: Clone = (T, T);