2024-05-22 09:04:12 -04:00
|
|
|
trait SomeTrait {
|
2022-02-25 11:41:36 -05:00
|
|
|
fn some_function(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-22 09:04:12 -04:00
|
|
|
trait OtherTrait {
|
2022-02-25 11:41:36 -05:00
|
|
|
fn other_function(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-27 06:29:25 -04:00
|
|
|
struct SomeStruct;
|
2022-02-25 11:41:36 -05:00
|
|
|
impl SomeTrait for SomeStruct {}
|
|
|
|
impl OtherTrait for SomeStruct {}
|
2024-06-27 06:29:25 -04:00
|
|
|
|
|
|
|
struct OtherStruct;
|
2022-08-07 14:51:16 -04:00
|
|
|
impl SomeTrait for OtherStruct {}
|
|
|
|
impl OtherTrait for OtherStruct {}
|
2022-02-25 11:41:36 -05:00
|
|
|
|
2024-06-27 06:29:25 -04:00
|
|
|
// TODO: Fix the compiler error by only changing the signature of this function.
|
|
|
|
fn some_func(item: ???) -> bool {
|
2022-02-25 11:41:36 -05:00
|
|
|
item.some_function() && item.other_function()
|
|
|
|
}
|
|
|
|
|
2022-08-07 14:51:16 -04:00
|
|
|
fn main() {
|
2024-06-27 06:29:25 -04:00
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_some_func() {
|
|
|
|
assert!(some_func(SomeStruct));
|
|
|
|
assert!(some_func(OtherStruct));
|
|
|
|
}
|
2022-08-07 14:51:16 -04:00
|
|
|
}
|