I'd like to read an example of this code being expressed within a rain/twig snippet as well.
Hi and thanks for the question!
It is not possible to display the products from a chosen category directly within the template editor.
While you are able to add featured categories (under Design > Featured Categories), the products within that category are not present as data available to the homepage.
You can use the Featured Products option (under Design > Featured Products), to display certain products on your homepage.