Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming

Rust 1.32.0 Stable Release Includes New Debugging Macro, 'Quality of Life' Improvements (rust-lang.org) 96

An anonymous reader summarizes the changes in Thursday's release of Rust 1.32.0 stable: "Quality of life" improvements include a new dbg macro to easily print values for debugging without having to use a println statement. For example, dbg!(x); prints the filename and line number, as well as the variable's name and value, to stderr (rather than to standard output). Making it even more useful, the macro also returns the value of what it's debugging -- even all the boolean values returned by each execution of an if-then statement.

Rust macros can now match literals of any type (string, numeric, char) -- and the 2018 edition of Rust also allows ? for matching zero or one repetitions of a pattern.

In addition, all integral numeric primitives now provide conversion functions to and from byte-arrays with specified endianness.

This discussion has been archived. No new comments can be posted.

Rust 1.32.0 Stable Release Includes New Debugging Macro, 'Quality of Life' Improvements

Comments Filter:
  • Why Rust (Score:3, Interesting)

    by 110010001000 ( 697113 ) on Saturday January 19, 2019 @01:52PM (#57987352) Homepage Journal
    Why did they call a language "Rust"? Did they think that was descriptive, or cute, or what? Is it an acronym? I understand things like "Swift" and "Go", but "Rust"doesn't make any sense.
    • Reportedly because the language doesn't intend to be something new or revolutionary: the authors want to collect the good ideas of past languages, and put them to use. They try to not add features of programming languages that were created in the last decade, for example.

      That doesn't mean the features they choose were implemented in popular languages: some were just implemented in research languages.
    • by Anonymous Coward

      Possibly a pun on the fact that it is meant to be close to the metal?

    • by DrXym ( 126579 )
      Nor does Python, Java, Ruby etc. Maybe it's just a distinctive moniker for the language.
    • No joke, supposedly named after a fungus [stackoverflow.com].

      And you know the answer is right, since it comes from Stack Overflow!

      Which on the other hand references Reddit, so... hmm.

    • Why did they call a language "Rust"?

      To better fit in with all the other terrible names geeks have come up with, of course. Gimp? Ogg Vorbis? Gnu Hurd?

  • by Anonymous Coward

    Is a way to print the type of an expression.
    Due to various reasons it's sometimes not clear what the exact type of an expression will be, so you have to give it an invalid type so the compiler will complain with the real type, and then you can copy paste that one.
    Kind of annoying.

    • by DrXym ( 126579 )
      Use the Rust plugin for VS Code, or for IntelliJ / Clion and it will show you the inferred type.
    • Yep. The RLS is a little bit primitive that way and doesn't have this yet, I think.

  • by MarchHare ( 82901 ) on Saturday January 19, 2019 @03:46PM (#57987784)

    Did he Rust maintainers have to implement the dbg!() method, or could any Rust dev add their own? I know in Ruby I could have created my own:

    def dbg!(x)
          STDERR.print "#{__FILE__}:#{__LINE__} #{x.inspect}\n"
          x
    end

    Just curious, don't know how flexible Rust is when it comes to extending the language itself.

    • Woops. Replying ot myself. Just realized my code prints the filename and line number of the dbg!() method itself, not its caller. I shoudl have parsed caller[0] instead...

    • It's relatively straight forward to implement. Rust has macros which are quite nicely integrated into the language.

      My experience of Rust macros is that you can do most things that you want with them, but you can't actually extend the language because they are not that flexible at matching syntax. It's not like lisp where you can't really tell whether you are using a language built-in or a macro.

      So, I think that you would find Ruby is more flexible as a language. But it's probably one of the reasons that Rus

Solutions are obvious if one only has the optical power to observe them over the horizon. -- K.A. Arsdall

Working...