This is taken from the book Organic Chemistry as a Second Language from page 35. In the following image:
It is seen that when the electrons from the double bond are pushed into the lone pair electrons, we get 2 electrons as a lone pair. And when a lone pair electrons are pushed to from a double bond we remove 2 electrons from the oxygen.
The part that confuses me is how the electrons are being counted (especially for octet rule). Let's take the example of oxygen that starts out double bonded (the molecule left of the double headed arrows) and then the double bond electrons get pushed into a lone pair (Oxygen on the right of the double headed arrow with a formal charge of 1). If I count the first oxygen (double bonded oxygen to the left of the double headed arrow), I get 6 electrons where the double bond counts as 1 electron for each bond, now if I go to the right of the arrow I see that same oxygen I count 7 electrons. How can a lone pair which is made up of 2 electrons result as being counted as 1 electron when it becomes part of a bond or vice versa?