def last_non_whitespace_position(view):
    """
    Returns the position of the last non-whitespace character of <view>.
    Returns -1 if <view> only contains non-whitespace characters.
    """
    pos = view.size() - 1
    while pos >= 0 and view.substr(pos).isspace():
        pos -= 1
    return pos