1 #![allow(unused_assignments)]
2 // expect-exit-status-1
4 struct Firework
<T
> where T
: Copy
+ std
::fmt
::Display
{
8 impl<T
> Firework
<T
> where T
: Copy
+ std
::fmt
::Display
{
10 fn set_strength(&mut self, new_strength
: T
) {
11 self.strength
= new_strength
;
15 impl<T
> Drop
for Firework
<T
> where T
: Copy
+ std
::fmt
::Display
{
18 println
!("BOOM times {}!!!", self.strength
);
22 fn main() -> Result
<(),u8> {
23 let mut firecracker
= Firework { strength: 1 }
;
24 firecracker
.set_strength(2);
26 let mut tnt
= Firework { strength: 100.1 }
;
27 tnt
.set_strength(200.1);
28 tnt
.set_strength(300.3);
31 println
!("Exiting with error...");
33 } // The remaining lines below have no coverage because `if true` (with the constant literal
34 // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`.
35 // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown
36 // in other tests, the lines below would have coverage (which would show they had `0`
37 // executions, assuming the condition still evaluated to `true`).
39 let _
= Firework { strength: 1000 }
;
44 // Expected program output:
45 // Exiting with error...