Skip to content

Instantly share code, notes, and snippets.

View Verdagon's full-sized avatar

Evan Ovadia Verdagon

View GitHub Profile
// Seamless C->Rust example: reversing a string
// Import types. More advanced compilers with generics wouldn't need
// to specify these generic args in theory, it would basically be a
// vanilla java import.
#pragma rsuse Str = &str
#pragma rsuse String = std::string::String
#pragma rsuse Chars = core::str::Chars<'static>
#pragma rsuse RevChars = core::iter::Rev<Chars>
// Import methods. More advanced compilers with generics won't need
// Seamless C->Rust example: reversing a string
// Import types. More advanced compilers with generics wouldn't need
// to specify these generic args in theory, it would basically be a
// vanilla java import.
#pragma rsuse Str = &str
#pragma rsuse String = std::string::String
#pragma rsuse Chars = core::str::Chars<'static>
#pragma rsuse RevChars = core::iter::Rev<Chars>
// Import methods. More advanced compilers with generics won't need
// Seamless C->Rust example: reversing a string
// Import types. More advanced compilers with generics wouldn't need
// to specify these generic args in theory, it would basically be a
// vanilla java import.
#pragma rsuse Str = &str
#pragma rsuse String = std::string::String
#pragma rsuse Chars = core::str::Chars<'static>
#pragma rsuse RevChars = core::iter::Rev<Chars>
// Import methods. More advanced compilers with generics won't need
#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>
% ./main -m ../mixtral/mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf -t 8 -n 1 -p "<|system|>You are a helpful assistant that only ever answers Yes or No. You answer one word then immediately stop, with nothing else in the response, not even punctuation or space, just one word Yes or no.<|im_end|><|im_start|>Is 11134 an even number? Answer yes or no, nothing else.</s><|assistant|>"
Log start
main: build = 2392 (bb6d00bb)
main: built with Apple clang version 14.0.3 (clang-1403.0.22.14.1) for arm64-apple-darwin23.4.0
main: seed = 1713222923
llama_model_loader: loaded meta data with 26 key-value pairs and 995 tensors from ../mixtral/mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv 0: general.architecture str = llama
llama_model_loader: - kv 1: general.name str = mistralai_mixtral-8x7b-instruct-v0.1
l

For example, if we have normal rust function:

pub fn kork(zork: u64) -> bool

We'd generate this Rust wrapper library code:

#[no_mangle]
pub extern "C" fn kork_extern(zork: u64) -> bool {
    inner_lib::kork(zork)

let's make a rust wrapper library and a C header for my normal "inner" rust library, so that my C program can take advantage of rust's standard library.

For example, if we have normal rust function:

pub fn kork(zork: u64) -> bool

Then we would generate this Rust wrapper library code:

#[no_mangle] pub extern "C" fn kork_extern(zork: u64) -> bool {

Greetings, Vale sponsors!
Because of some medical reasons*, I have to take an extended break from the coding side of Vale. I asked GitHub to pause the ValeLang sponsors account, which they unfortunately said is impossible. Given the unknown timeframe (and that I've been leaning toward switching to Patreon eventually anyway), I'll be closing the ValeLang sponsors account in a couple days.
Vale isn't going away! It's one of my favorite things to do (and blog about) but it could be some time before it's back in full swing. When the time comes, I plan on returning slowly, doing some light bug fixes, making some articles, and when I'm back at full-speed, finishing the long-awaited Vale 0.3 "Angband" release.
In case some of our paths don't cross again: thank you for sponsoring! Your support has been inspiring and uplifting, and it's amazing to see that so many of us share the excitement and hope for easier high-performance code. Your support has helped me get through some pretty tough challenges (especially reg
Greetings, Vale sponsors!
Because of some medical reasons*, I have to take an extended break from the coding side of Vale. I asked GitHub to pause the ValeLang sponsors account, which they unfortunately said is impossible. Given the unknown timeframe (and that I've been leaning toward switching to Patreon eventually anyway), I'll be closing the ValeLang sponsors account in a couple days.
Vale isn't going away! It's one of my favorite things to do (and blog about) but it could be some time before it's back in full swing. When the time comes, I plan on returning slowly, doing some light bug fixes, making some articles, and when I'm back at full-speed, finishing the long-awaited Vale 0.3 "Angband" release.
In case some of our paths don't cross again: thank you for sponsoring! Your support has been inspiring and uplifting, and it's amazing to see that so many of us share the excitement and hope for easier high-performance code. Your support has helped me get through some pretty tough challenges (especially reg
@Verdagon
Verdagon / gist:569271232a94495bc3b38cd8d7469634
Created December 19, 2023 02:48
Closing ValeLang sponsors account
Greetings, Vale sponsors!
Because of some medical reasons*, I have to take an extended break from the coding side of Vale. I asked GitHub to pause the ValeLang sponsors account, which they unfortunately said is impossible. Given the unknown timeframe (and that I've been leaning toward switching to Patreon eventually anyway), I'll be closing the ValeLang sponsors account in a couple days.
Vale isn't going away! It's one of my favorite things to do (and blog about) but it could be some time before it's back in full swing. When the time comes, I plan on returning slowly, doing some light bug fixes, making some articles, and when I'm back at full-speed, finishing the long-awaited Vale 0.3 "Angband" release.
In case some of our paths don't cross again: thank you for sponsoring! Your support has been inspiring and uplifting, and it's amazing to see that so many of us share the excitement and hope for easier high-performance code. Your support has helped me get through some pretty tough challenges (especially reg