Skip to content

remove semicolon for suppressed the expressions to unit #19699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
He-Pin opened this issue Dec 10, 2014 · 4 comments
Closed

remove semicolon for suppressed the expressions to unit #19699

He-Pin opened this issue Dec 10, 2014 · 4 comments

Comments

@He-Pin
Copy link

He-Pin commented Dec 10, 2014

Hi I am new to rust,and when I am reading examples from rust by example,I found this one is really confusing.

This may not always be desired, so the output can be suppressed by ending the expression with a semicolon ;

why not just make the return type as unit,then the return type of the expression just been ignored just like scala.

@steveklabnik
Copy link
Member

Please open an issue on Rust by Example, rather than on Rust itself.

@He-Pin
Copy link
Author

He-Pin commented Dec 10, 2014

this is the rust issue.
I would like to write

 let z:()= {
        // The semicolon suppresses this expression and `()` is assigned to `z`
        2 * x
    }

or

 let z= {
        // The semicolon suppresses this expression and `()` is assigned to `z`
        2 * x
      ()
    }

@steveklabnik
Copy link
Member

If you're interested in changing the semantics of the language, then the appropriate venue is https://github.com/rust-lang/rfcs , as all significant semantics must go through one.

@He-Pin
Copy link
Author

He-Pin commented Dec 10, 2014

@steveklabnik thanks ,very open and nice.

lnicola pushed a commit to lnicola/rust that referenced this issue May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants