Quantum rings of arbitrary shape and non-uniform width in a threading magnetic field