Created
May 20, 2024 20:24
-
-
Save Verdagon/b283a0de38a6e27a6be4550db933b9c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma rsuse Str = &str | |
#pragma rsuse Str_chars = str::chars | |
#pragma rsuse String = std::string::String | |
#pragma rsuse String_as_str = String::as_str | |
#pragma rsuse String_drop = String::drop | |
#pragma rsuse Chars = core::str::Chars<'static> | |
#pragma rsuse Chars_rev = Chars::rev | |
#pragma rsuse RevChars = core::iter::Rev<Chars> | |
#pragma rsuse RevChars_collectString = RevChars::collect::<String> | |
#include <rust_deps/rust_deps.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
Str constant = VR_StrFromCStr("bork"); | |
Chars x = Str_chars(constant); | |
RevChars reversed = Chars_rev(x); | |
String bork = RevChars_collectString(reversed); | |
Str bork_as_str = String_as_str(&bork); | |
// Prints "krob" | |
write(STDOUT_FILENO, VR_StrToCStr(bork_as_str), VR_StrLen(bork_as_str)); | |
String_drop(&bork); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment