1. 37
    Rustlings macros4: Using rustfmt to fix common syntax issues
    49s

Rustlings macros4: Using rustfmt to fix common syntax issues

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

README for this exercise.

Chris Biscardi: [0:00] In macros4, we define a macro using the macro_rules! Macro that has two implementations. One is a function that doesn't take any arguments, and one is a function that takes an expression. In both cases, we use the println! Macro to print out the value.

[0:14] In our main() function, we have my_macro called with no arguments followed by my_macro called with (7777). The Rust compiler tells us that no rules expected the token '('. In this case, all I'm going to do is insert a space and save. Note that our tests are now passing. This is because the semi colons were inserted for me by rustfmt.

[0:36] Rustfmt is a tool for formatting Rust code similar to Prettier in the JavaScript ecosystem or gofmt. It's an incredibly useful tool, as we just saw in this module, and you can set it up to be run in your editor.

egghead
egghead
~ 12 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today