Commutation
Let us look at the process when the current is transferred from one switch to the other. For this we extend the circuit with an output voltage source. This source models some output voltage of our circuit to which a load is connected. If, for example, we want to charge a smartphone from a cigarette lighter, the input voltage would be the cigarette lighter with UEin = 12 V, and the output voltage would be UAus = 5 V for the charger. We consider the case in which a charging current of 1 A is already flowing into the smartphone.
First we close switch 1 and open switch 2. We hold this state for the time t = 1 ms. The current path is marked in red. From the mesh equation we determine the inductor voltage. From this we can see how the current behaves. We have:

Because the inductor voltage is positive, the current rises. The current flows through switch 1, the inductor and the two sources.
Now we commutate the current to switch 2. To do this, we open switch 1 and close switch 2. The current in the inductor is continuous, so it continues to flow from left to right. We hold this state for 1.4 ms.

Because the inductor voltage is now negative, the current in the inductor falls. It flows through switch 2, the inductor and the output voltage. We have to hold the second state somewhat longer; then the current reaches the value of 1 A again.
The inductor voltage depends on the switch position. The sign of the inductor voltage determines whether the current rises or falls. The magnitude and duration of the voltage determine how quickly the current changes.
The inductor voltage can become positive and negative as soon as we add an output voltage with U > 0 to a half bridge. In practice this condition is usually met. With positive and negative inductor voltages we can set any current. If, for example, the current is too high, we reduce the duty cycle of the PWM below the value at which the current remains constant (here UAus / UEin = 5 V / 12 V ≈ 42 %). The negative voltage is then applied to the inductor for longer than the positive voltage. The current then falls for longer than it rises. We maintain this state until the current has fallen to the desired value.
The smaller the duty cycle chosen, the faster we reach the target current.