I hereby claim:
- I am phaazon on github.
- I am phaazon (https://keybase.io/phaazon) on keybase.
- I have a public key whose fingerprint is 3943 DF2A 2E41 24B4 5702 E6BC 4F28 29BB 996A 2EED
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| {-# LANGUAGE RankNTypes #-} | |
| -- A natural transformation. | |
| data NT f g = NT { nt :: forall a. f a -> g a } | |
| -- Natural transformation from Maybe to []. | |
| maybeListNT :: NT Maybe [] | |
| maybeListNT = NT (maybe [] pure) |
| fn correct<F>(f: F) where F: for<'a> FnOnce(&'a u32) { | |
| f(&3) | |
| } | |
| fn dafuck<F>(f: F) where for<'a> F: FnOnce(&'a u32) { | |
| f(&3) | |
| } | |
| fn main() { | |
| correct(|x| println!("{}", x)); |
| package main | |
| import "fmt" | |
| func fibonacci() func() int { | |
| a := 0 | |
| b := 1 | |
| return func() int { | |
| c := a | |
| a, b = b, a + b |
| extern crate luminance; | |
| extern crate luminance_glfw; | |
| use luminance::framebuffer::Framebuffer; | |
| use luminance::pipeline::{entry, pipeline}; | |
| use luminance::shader::program::{Program, ProgramError, Uniform, UniformBuilder, UniformInterface, UniformWarning}; | |
| use luminance::tess::{Mode, Tess, TessVertices}; | |
| use luminance_glfw::{Action, Device, Key, WindowDim, WindowOpt, WindowEvent}; | |
| use std::time::Instant; |
| // g++ main.cpp -std=c++17 -W -Wall -pedantic | |
| #include <cstdlib> | |
| #include <cstdint> | |
| #include <functional> | |
| auto foo() -> std::function<void ()> { | |
| int32_t a = 317; | |
| return [&a]() { |
| // Without compiling nor running the following program, what do you expect its output to be? :) | |
| // Have a great monday! | |
| fn main() { | |
| let mut a: u16 = 42; | |
| let b: u16 = 7; | |
| println!("before, a: {}\tb: {}", a, b); | |
| unsafe { foo(&mut a as *mut u16 as *mut u32); } |
| // The problem arises as I have the following type representing a cache | |
| struct Cache { | |
| foo_data: Vec<Foo>, | |
| bar_data: Vec<Bar>, | |
| // ... | |
| } | |
| // So, there’s a function called get_by_id() that basically takes an index into a one of the Vec<T> above and returns an Option<&T>. | |
| // Though, because of resource dependency, that function takes a mutable Cache so that, in a trait implementation for each type, | |
| // you can ask for a load of another resource in the cache: |
| 14:07 < phaazon> is there a way to have access to mmap in rust? | |
| 14:08 < kimundi> phaazon: Sure, and there are crates for it too | |
| 14:08 < phaazon> kimundi: I thought it’d be in libc | |
| 14:08 < kimundi> phaazon: The main issue is just that it is unsafe to create a safe slice from the memroy region returned by it if it backs a file | |
| 14:08 < phaazon> https://docs.rs/libc/0.2.17/libc/fn.mmap.html | |
| 14:08 < phaazon> ok, it is :D | |
| 14:09 < phaazon> kimundi: I’m actually discovering the use of mmap | |
| 14:09 < phaazon> I don’t quite really get the point | |
| 14:09 < phaazon> if I understand correctly, it creates a mapping from a file into RAM | |
| 14:09 < kimundi> yes |
| coin |