- When is it appropriate to use an associated type versus a generic type?
- https://stackoverflow.com/questions/32059370/when-is-it-appropriate-to-use-an-associated-type-versus-a-generic-type
This example shows how to pass rust closure as C callback without need of Box type (nostd; no liballoc); Created for the the implementation of thread::spawn for FreeRTOS (rust-idf)
Only requirement - malloc and free functions
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
use std::marker::PhantomData; | |
struct Unconcrete; | |
struct One; | |
struct Two; | |
struct Three; | |
struct Four; | |
struct Five; |
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
use core::sync::atomic::{ AtomicU32, Ordering }; | |
struct Part { | |
val: u32, | |
} | |
struct Data { | |
a: Part, | |
b: Part, | |
} |
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 rayon; | |
use rayon::prelude::*; | |
use std::marker::PhantomData; | |
use std::mem; | |
struct Storage<'a, T : 'a> | |
{ | |
ptr: *mut T, | |
phantom: PhantomData<&'a T>, |
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 rayon; | |
use rayon::prelude::*; | |
struct State<'a> | |
{ | |
first: &'a [usize], | |
other: &'a mut [usize], | |
value: Option<(&'a [usize], &'a mut [usize], &'a [usize])>, | |
} |
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
/* Vladislav Nikonov [2018] | |
* | |
* This class represents read-write lock proxy for any type. Writer always have higest | |
* entrance priority (e.g. if object was already locked by readers - no new readers allowed before | |
* writer exit from lock. | |
*/ | |
#include <mutex> | |
#include <shared_mutex> | |
#include <chrono> |
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
/* Vladislav Nikonov [2018] | |
* | |
* Template visitor implementation, which will wait for concrete visitor dispatch, | |
* and will throw on other events. This can be done by method overload based on template type. | |
* This method will be overriden by function call, provided by client code | |
*/ | |
#include <iostream> | |
#include <memory> | |
#include <vector> |
NewerOlder