This works with any kind of weapon, i.e. rifles, pistols and launchers.
If there is an empty weapon on the ground and you have a magazine for it in your inventory, picking up the weapon will cause that magazine to be loaded into it instantly. (No reloading animation.)
This also works if you drop the weapon and instantly pick it back up, which can be exploited to quickly re-load rocket launchers, for example.