you are viewing a single comment's thread
view the rest of the comments
[–] 57 points 3 years ago (1 child)

int unused_variable = 0;

Dude wtf is your problem don’t just leave things lying about there don’t you know how to code I mean what the- I don’t go to your house and leave shit on the floor and just—

int _unused_variable = 0;

Ok. We cool.

  • source
  • hideshow 1 child comment
  • [–] 1 point 2 years ago

    sometimes you need an unused variable. some uses in rust:

    // destructuring
    let (width, _height) = get_dimensions();
    
    // trait implementations (i couldnt think of a better example for this)
    impl Into for AlwaysZero {
        fn into(_value: Self) -> {
            return 0;
        }
    }
    
    // some types (eg. Result) must be 'used'
    // assigned to a variable if we dont care about the return value
    let _ = returns_result("foo");
    
  • source
  • parent