Write a code snippet to reverse a string while maintaining the spaces.
Implement reverse_string(s), returning a new string with all non-space characters reversed while each space remains at its original index. The input is a string, and spaces are represented by the literal character " "; return a string of the same length.
def reverse_string(s):