diff options
author | innokentii <innokentii@yandex-team.com> | 2022-12-13 10:47:00 +0300 |
---|---|---|
committer | innokentii <innokentii@yandex-team.com> | 2022-12-13 10:47:00 +0300 |
commit | 02efb5d0f40aa0169d1fe65e769dde0e53fb8900 (patch) | |
tree | 7329db1a177a0ad007e3a945041e5921e328e641 /library | |
parent | bba9b658c4fdea76142605378b7e381100a5b96d (diff) | |
download | ydb-02efb5d0f40aa0169d1fe65e769dde0e53fb8900.tar.gz |
Add TStringBuf conversion operator for TSharedData
add TStringBuf conversion operator
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/actors/util/shared_data.h | 4 | ||||
-rw-r--r-- | library/cpp/actors/util/shared_data_ut.cpp | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/library/cpp/actors/util/shared_data.h b/library/cpp/actors/util/shared_data.h index 8425738578..753eb85d07 100644 --- a/library/cpp/actors/util/shared_data.h +++ b/library/cpp/actors/util/shared_data.h @@ -135,6 +135,10 @@ namespace NActors { return { Data_ + pos, len }; } + explicit operator TStringBuf() const noexcept { + return Slice(); + } + bool IsPrivate() const { return Data_ ? IsPrivate(Header()) : true; } diff --git a/library/cpp/actors/util/shared_data_ut.cpp b/library/cpp/actors/util/shared_data_ut.cpp index 0a510122b4..af38fc8f0c 100644 --- a/library/cpp/actors/util/shared_data_ut.cpp +++ b/library/cpp/actors/util/shared_data_ut.cpp @@ -38,6 +38,7 @@ namespace NActors { UNIT_ASSERT(!link.IsShared()); UNIT_ASSERT(!data.IsShared()); + UNIT_ASSERT_VALUES_EQUAL(TString(TStringBuf(data)), TString("Hello")); UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice()), TString("Hello")); UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(1)), TString("ello")); UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(1, 3)), TString("ell")); |