#include #include #include static const char* empty = ""; StringView::StringView() { m_string = empty; m_length = 0; } StringView::StringView(const StringView& other) { m_string = other.m_string; m_length = other.m_length; } StringView::StringView(const char* c_str) { check(c_str); m_string = c_str; m_length = strlen(m_string); } StringView::StringView(const char* c_str, usize length) { check(c_str); m_string = c_str; m_length = length; } const char& StringView::operator[](usize index) const { expect(index < m_length, "index out of range"); return m_string[index]; } Result StringView::to_string() { return String::from_cstring(m_string); }