#ifndef BASE_STRINGS_STRING_VIEW_RUST_H_
#define BASE_STRINGS_STRING_VIEW_RUST_H_
#include <stdint.h>
#include <string_view>
#include "build/build_config.h"
#include "third_party/rust/cxx/v1/cxx.h"
namespace base {
inline rust::Str StringViewToRustStrUTF8(std::string_view string_piece) {
return rust::Str(string_piece.data(), string_piece.size());
}
inline rust::Slice<const uint8_t> StringViewToRustSlice(
std::string_view string_piece) {
return rust::Slice<const uint8_t>(
reinterpret_cast<const uint8_t*>(string_piece.data()),
string_piece.length() * sizeof(std::string_view::value_type));
}
inline std::string_view RustStrToStringView(rust::Str str) {
return std::string_view(str.data(), str.size());
}
}
#endif