- 1 × battery
- 1 × iron plate
- 1 × copper plate
- 2 × sulfuric acid
- 10 × water
- 1 × iron plate
- 5 × sulfur
- 3 × water
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
{-# 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) |
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
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)); |
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
package main | |
import "fmt" | |
func fibonacci() func() int { | |
a := 0 | |
b := 1 | |
return func() int { | |
c := a | |
a, b = b, a + b |
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
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; |
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
// 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]() { |
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
// 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); } |
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
// 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: |
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
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 |
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
coin |