Having some kind of debugging tool in our belt is extremely useful before writing a lot of code. In this lesson we build a println!()-style syntax using JavaScript’s console.log to be able to log out values in Rust.
A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.
Instructor: Before we write much more code, we will want to have some debugging tools in our belt. One simple but still effective tool for investigating our programs is logging.
In JavaScript, the console log function is the way to log messages to the browser's developer tool console. Using Rust [inaudible] , we can import a reference to it. Using the Rust macro, we can provide a [inaudible] style syntax for console log, logging from Rust.
In our run function, we now can use the log macro and log the side value to the console. We reload the page in our browser and can see the meaning of life is 42. Great, our macro worked.
The extern "C" code block isn't in my ./crate/src/lib.rs file?
@Jack the "C" is not mandatory as far as I know or what do you mean?