Use maybe_t in string_last_char

This commit is contained in:
ridiculousfish 2019-09-14 11:56:02 -07:00
parent 0ecfc25961
commit cc5e29734b

View File

@ -1277,9 +1277,10 @@ wcstring debug_escape(const wcstring &in) {
return result;
}
/// Helper to return the last character in a string, or NOT_A_WCHAR.
static wint_t string_last_char(const wcstring &str) {
return str.empty() ? NOT_A_WCHAR : str.back();
/// Helper to return the last character in a string, or none.
static maybe_t<wchar_t> string_last_char(const wcstring &str) {
if (str.empty()) return none();
return str.back();
}
/// Given a null terminated string starting with a backslash, read the escape as if it is unquoted,