• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile / rustracing / 9526165797

15 Jun 2024 06:30AM UTC coverage: 74.576%. Remained the same
9526165797

push

github

web-flow
Merge pull request #16 from sile/fix-lint-error

Fix clippy errors

1 of 1 new or added line in 1 file covered. (100.0%)

264 of 354 relevant lines covered (74.58%)

2.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/convert.rs
1
//! Traits for conversions between types.
2

3
/// A cheap reference-to-reference conversion that has a possibility to fail.
4
pub trait MaybeAsRef<T: ?Sized> {
5
    /// Performs the conversion.
6
    fn maybe_as_ref(&self) -> Option<&T>;
7
}
8
impl<T, U> MaybeAsRef<T> for Option<U>
9
where
10
    U: MaybeAsRef<T>,
11
{
12
    fn maybe_as_ref(&self) -> Option<&T> {
13
        self.as_ref().and_then(|u| u.maybe_as_ref())
14
    }
15
}
16

17
#[cfg(test)]
18
mod tests {
19
    use super::*;
20

21
    #[test]
22
    fn it_works() {
2✔
23
        struct Foo;
24
        struct Bar(Foo);
25
        impl MaybeAsRef<Foo> for Bar {
26
            fn maybe_as_ref(&self) -> Option<&Foo> {
1✔
27
                Some(&self.0)
1✔
28
            }
1✔
29
        }
30

31
        let bar = Bar(Foo);
32
        assert!(bar.maybe_as_ref().is_some());
1✔
33
    }
2✔
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc