Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions support/annotations_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
#define CRUBIT_LIFETIME_BOUND
#endif
#define crubit_nonnull _Nonnull
#define crubit_nullable _Nullable
#else
#define CRUBIT_TRIVIAL_ABI
#define CRUBIT_VIEW
#define CRUBIT_LIFETIME_BOUND
#define crubit_nonnull
#define crubit_nullable
#endif

// Style waiver granted in crubit.rs-style-waiver-attribute-annotate
Expand Down
14 changes: 9 additions & 5 deletions support/rs_std/str_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ class CRUBIT_INTERNAL_RUST_TYPE("&str") CRUBIT_TRIVIAL_ABI StrRef final {
constexpr size_t len() const noexcept { return slice_.size(); }
constexpr bool empty() const noexcept { return slice_.size() == 0; }

constexpr const char* data() const noexcept { return slice_.data(); }
constexpr const char* crubit_nullable data() const noexcept {
return slice_.data();
}
constexpr size_t size() const noexcept { return slice_.size(); }

constexpr std::string_view to_string_view() const noexcept {
Expand Down Expand Up @@ -158,11 +160,11 @@ constexpr bool operator==(std::string_view lhs, StrRef rhs) noexcept {
return rhs == lhs;
}

constexpr bool operator==(StrRef lhs, const char* rhs) noexcept {
constexpr bool operator==(StrRef lhs, const char* crubit_nonnull rhs) noexcept {
return lhs.to_string_view() == std::string_view(rhs);
}

constexpr bool operator==(const char* lhs, StrRef rhs) noexcept {
constexpr bool operator==(const char* crubit_nonnull lhs, StrRef rhs) noexcept {
return rhs == lhs;
}

Expand All @@ -178,11 +180,13 @@ constexpr auto operator<=>(std::string_view lhs, StrRef rhs) noexcept {
return lhs <=> rhs.to_string_view();
}

constexpr auto operator<=>(StrRef lhs, const char* rhs) noexcept {
constexpr auto operator<=>(StrRef lhs,
const char* crubit_nonnull rhs) noexcept {
return lhs.to_string_view() <=> std::string_view(rhs);
}

constexpr auto operator<=>(const char* lhs, StrRef rhs) noexcept {
constexpr auto operator<=>(const char* crubit_nonnull lhs,
StrRef rhs) noexcept {
return std::string_view(lhs) <=> rhs.to_string_view();
}

Expand Down