2015-02-06 04:02:59 -06:00
|
|
|
#![crate_type="lib"]
|
|
|
|
|
2015-04-06 15:49:30 -05:00
|
|
|
// @has assoc_types/trait.Index.html
|
2015-02-06 04:02:59 -06:00
|
|
|
pub trait Index<I: ?Sized> {
|
2022-07-02 05:43:33 -05:00
|
|
|
// @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized'
|
2015-02-06 04:02:59 -06:00
|
|
|
type Output: ?Sized;
|
2021-07-25 16:41:57 -05:00
|
|
|
// @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \
|
2015-02-06 04:02:59 -06:00
|
|
|
// "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
|
2021-07-25 16:41:57 -05:00
|
|
|
// @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]//a[@href="trait.Index.html#associatedtype.Output"]' \
|
2017-06-11 12:20:48 -05:00
|
|
|
// "Output"
|
2015-02-06 04:02:59 -06:00
|
|
|
fn index<'a>(&'a self, index: I) -> &'a Self::Output;
|
|
|
|
}
|
2015-05-25 08:06:38 -05:00
|
|
|
|
|
|
|
// @has assoc_types/fn.use_output.html
|
2023-01-30 12:05:12 -06:00
|
|
|
// @has - '//pre[@class="rust item-decl"]' '-> &T::Output'
|
|
|
|
// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Index.html#associatedtype.Output"]' 'Output'
|
2015-05-25 08:06:38 -05:00
|
|
|
pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
|
|
|
|
obj.index(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Feed {
|
|
|
|
type Input;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has assoc_types/fn.use_input.html
|
2023-01-30 12:05:12 -06:00
|
|
|
// @has - '//pre[@class="rust item-decl"]' 'T::Input'
|
|
|
|
// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input'
|
2015-05-25 08:06:38 -05:00
|
|
|
pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
|
|
|
|
|
|
|
|
// @has assoc_types/fn.cmp_input.html
|
2023-01-30 12:05:12 -06:00
|
|
|
// @has - '//pre[@class="rust item-decl"]' 'where T::Input: PartialEq<U::Input>'
|
|
|
|
// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input'
|
2015-05-25 08:06:38 -05:00
|
|
|
pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
|
|
|
|
where T::Input: PartialEq<U::Input>
|
|
|
|
{
|
|
|
|
a == b
|
|
|
|
}
|