Go to definition in Emacs

Today, I was reading Why Use Structured Errors in Rust Applications? and one of the issues discussed is jumping away from the code you're working on to look at the definition of the error. On the one hand, rust-analyzer makes it really easy to jump to the error, but on the other hand they felt that they sometimes had to do so unnecessarily.

In the comments on lobste.rs, matklad mentioned that he recently adopted the habit of splitting the screen first and going to the definition in the split (in Emacs terms, in the other window).

I use M-. (xref-find-definitions) frequently to jump to a definition when I'm programming Rust. Eglot uses rust-analyzer to provide xref the ability to find the definition perfectly. Then I typically use M-, (xref-go-back) to jump back.

Following matklad's suggestion, I could instead use C-x 4 . (xref-find-definitions-other-window) to split the screen first. Then I could look at both the code and the definition at the same time. Instead of jumping back, I could C-x 0 (delete-window) to delete the current window, leaving me in the original window. I think I'm going to give this workflow a try.

screenshot of Emacs window

I suppose you could also use C-x 5 . (xref-find-definitions-other-frame) and C-x 5 0 (delete-frame) to do the analogous thing with frames.