There are any number of retaining rings, circlips and other items that do as you suggest, and used as a means to secure a fitting on a shaft, but allow for a certain amount of play - e.g. the circlips that hold the fan on a dryer motor, that also rotates the drum from the other end.
Or, it could be a torsion-spring that is inserted in a device to hold something closed (or open). Its ID will increase somewhat when compressed (or closed, depending), and it is often inserted on a shaft with either a bump or an inlay to hold it in place.
https://www.mcmaster.com/springs
They come in all kinds of sizes and materials as well.
Peter Wieck
Melrose Park, PA