Implement a few methods for RingBuf

Part of collections reform part 1 and 2, #18424 and #19986

* shrink_to_fit
* swap_back_remove
* swap_front_remove
* truncate
* resize
Would appreciate a comment explaining this trick.