Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused_variables)]
- #![allow(dead_code)]
- use std::f32::consts::{PI, E};
- struct S(f32);
- //opt-in to custom drop behavior
- impl Drop for S {
- fn drop(&mut self) {
- println!("S::drop({:.4})", self.0);
- }
- }
- fn do_with_s(s: S) {
- println!("do_with_s({:.10})", s.0);
- }
- fn main() {
- println!("main::start");
- let stack_variable = S(PI);
- let heap_variable = Box::new( S(E) );
- do_with_s(stack_variable);
- println!("main::end");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement