Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::default::Default;
- #[derive(Debug)]
- pub struct Parameter {
- a: u32,
- b: u32,
- c: u32,
- }
- // Set default values for Parameter struct
- impl Default for Parameter {
- fn default() -> Self {
- Parameter { a: 2, b: 4, c: 6}
- }
- }
- fn some_calc(p: Parameter) -> u32 {
- let (a, b, c) = (p.a, p.b, p.c);
- a + b + c
- }
- fn main() {
- // Set default values for p except c
- let p = Parameter { c: 10, .. Parameter::default() };
- println!("{}", some_calc(p));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement