Small rifle primers are the same physical size (diameter and thickness) as small pistol primers.
Large rifle primers are the same diameter as large pistol primers, but thicker.
That means that putting a large rifle primer in a case designed for a large pistol primer will make the primer stand out beyond the case head (i.e., a "high primer"). A high primer is dangerous, because it can be set-off by things besides the firing pin. For example, if there is a cartridge with a high primer in a revolver, and a heavy-recoiling cartridge is fired in another chamber, the high primer can be banged against the recoil shield behind the cylinder hard enough to set-off the cartridge while the chamber it is in is not aligned with the barrel. That can mean that the bullet cannot get out of the chamber, and the cylinder will explode.
Also, using pistol primers in rifle cartridges that are fired at higher pressures can result in the pistol primer being pushed back against the firing pin hole hard enough for the primer to "pierce" and let hot gases flow back into the gun's firing mechanism, and potentially into your face. That can damage the gun and injure you.
Going the other way, using a rifle primer in a pistol cartridge might (or might not) result in the gun not being able to fire the cartridge because the gun's spring might not be powerful enough to hit the stronger rifle primer cup hard enough to set it off.
So, use the proper primers for the cartridge you aare loading, no matter what else fits.