This is my 17th weekly report.

# Diary

I began to translate Tokio tutorial to Japanese. This tutorial gave me a tremendous amount of knowledge of asynchronous programming, not only in Rust, but also in all programming languages. That's why I would like to share such a good tutorial with Japanese programmers.

By the way, my pull request about introducing Deno.resolveDns API to Deno is finally almost ready to land. It's been kind of tough work because of my insufficiency of DNS knowledge and the difficulty of deciding what interface this API should look like.

And yesterday, I ran into a very strange error when writing an integration test - this snippet does works (note that it's in the main function), but on the other hand, if I put the same stuff into a test annotated with #[tokio::test], the test does NOT work.

Do you know why? It took me about 3 hours to figure out. It's because #[tokio::main] and #[tokio::test] will be expanded differently - that's a tiny difference, but in my code it's big enough to prevent the test from working. I had thought it was really annoying, but once the reason came to light, it was very simple. The answer is:

When expanding #[tokio::main], we get:

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(async { /* snip */ });


On the other hand, for #[tokio::test], we get:

tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async { /* snip */ });


That's it.