Lukasz Anforowicz | 4bb78a7 | 2023-03-06 14:10:37 -0800 | [diff] [blame] | 1 | // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| 2 | // Exceptions. See /LICENSE for license information. |
| 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | |
| 5 | #ifndef CRUBIT_RS_BINDINGS_FROM_CC_TEST_FUNCTION_SIMPLE_SIMPLE_FUNCTIONS_H_ |
| 6 | #define CRUBIT_RS_BINDINGS_FROM_CC_TEST_FUNCTION_SIMPLE_SIMPLE_FUNCTIONS_H_ |
| 7 | |
| 8 | #pragma clang lifetime_elision |
| 9 | |
| 10 | #include "support/rs_std/rs_char.h" |
| 11 | |
| 12 | // Tests for round-tripping between: |
| 13 | // - Rust built-in `char` type |
| 14 | // - C++ `rs_std::rs_char` type (from `crubit/support/rs_std/rs_char.h`) |
| 15 | namespace rs_char_test { |
| 16 | |
| 17 | inline rs_std::rs_char NextChar(rs_std::rs_char c) { |
| 18 | return rs_std::rs_char::from_u32(std::uint32_t{c} + 1).value(); |
| 19 | } |
| 20 | |
| 21 | struct SomeStruct final { |
| 22 | rs_std::rs_char c; |
| 23 | |
| 24 | rs_std::rs_char GetChar() const { return c; } |
| 25 | }; |
| 26 | |
| 27 | using CharAlias = rs_std::rs_char; |
| 28 | inline CharAlias NextCharViaTypeAlias(CharAlias c) { |
| 29 | return CharAlias::from_u32(std::uint32_t{c} + 1).value(); |
| 30 | } |
| 31 | |
| 32 | namespace using_test { |
| 33 | using rs_std::rs_char; |
| 34 | } |
| 35 | inline using_test::rs_char NextCharViaImport(using_test::rs_char c) { |
| 36 | return using_test::rs_char::from_u32(std::uint32_t{c} + 1).value(); |
| 37 | } |
| 38 | |
| 39 | } // namespace rs_char_test |
| 40 | |
| 41 | #endif // CRUBIT_RS_BINDINGS_FROM_CC_TEST_FUNCTION_SIMPLE_SIMPLE_FUNCTIONS_H_ |