#include #include #include OwnedStringView::OwnedStringView() { } OwnedStringView::OwnedStringView(OwnedStringView&& other) { m_string = other.m_string; m_length = other.m_length; other.m_string = nullptr; } OwnedStringView::OwnedStringView(char* c_str) { m_string = c_str; if (m_string) { m_length = strlen(m_string); } } OwnedStringView::~OwnedStringView() { if (m_string) raw_free(m_string); } Result OwnedStringView::clone() const { char* const c_str = strdup(m_string); if (!c_str) return err(ENOMEM); return OwnedStringView{c_str}; } const char& OwnedStringView::operator[](usize index) const { expect(index < m_length, "index out of range"); return m_string[index]; }