blob: 36d43a7d26d5f195f4afcd6d144368cfad931965 [file] [log] [blame]
Lukasz Anforowicz4bb78a72023-03-06 14:10:37 -08001// 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`)
15namespace rs_char_test {
16
17inline 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
21struct SomeStruct final {
22 rs_std::rs_char c;
23
24 rs_std::rs_char GetChar() const { return c; }
25};
26
27using CharAlias = rs_std::rs_char;
28inline CharAlias NextCharViaTypeAlias(CharAlias c) {
29 return CharAlias::from_u32(std::uint32_t{c} + 1).value();
30}
31
32namespace using_test {
33using rs_std::rs_char;
34}
35inline 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_