Skip to content

Instantly share code, notes, and snippets.

@edhebi
edhebi / rust_modules.md
Created September 28, 2022 10:01
Rust modules guide

Rust modules and how to use them

So, how tf do rust modules work? and why tf are they not doing what I want right now???

Note: A bunch of things in here are defined by cargo and a few others by rust. I won't generally care about that distinction because two languages without standard build system is more than enough for my sanity.

➡️ Feel free to ask me on twitter if you have questions or remarks.

Core concepts

#!/bin/bash
clang -xc++ -std=c++17 -O3 - <<EOF
#include <cstdio>
#include <algorithm>
int main(){std::printf("%d\n",std::max({$(sed -e 's/[FL]/0/g;s/[BR]/1/g;/^$/d;s/^/0b/;s/$/,/' $1)}));}
EOF
#ifndef NEON_MATH_SWIZZLE_HPP
#define NEON_MATH_SWIZZLE_HPP
#include <neon/math/vec.hpp>
namespace neon::math
{
template <std::size_t N, typename T> constexpr auto x(vec_t<N, T> v) noexcept { return v.x; }
template <std::size_t N, typename T> constexpr auto y(vec_t<N, T> v) noexcept { return v.y; }
template <std::size_t N, typename T> constexpr auto z(vec_t<N, T> v) noexcept { return v.z; }
using System;
using System.IO;
namespace RealPath
{
class Program
{
static string RealPath(string path)
{
if (!File.Exists(path) && !Directory.Exists(path)) return path;
@edhebi
edhebi / launch.json
Created April 4, 2020 17:46
Basic vscode setup
{
"version": "0.2.0",
"configurations": [
{
"name": "g++",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,