1974 shaares
6 private links
6 private links
67 results
tagged
rust
union CellValue {
tag: TaggedPtr<Aligned, 2>,
num: Decimal,
str: ManuallyDrop<ThinVec<u8>>,
formula: ManuallyDrop<Rc<Formula>>,
iter: ManuallyDrop<Box<dyn Iterator<Item = CellValue>>>,
}
struct UsersService {
config: &'static Config,
}
struct OrdersService {
config: &'static Config,
}
// ...
fn load() -> Result<&'static Config, Error> {
// ...
return Ok(Box::leak(Box::new(config)));
}
// ...
let config = config::load()?;
let users_service = UsersService::new(config);
let orders_service = OrdersService::new(config);
User space scheduling
struct Id<T> {
inner: u64,
_marker: std::marker::PhantomData<T>,
}
impl<T> Id<T> {
pub fn new(inner: u64) -> Self {
Self {
inner,
_marker: std::marker::PhantomData
}
}
}
struct UserIdMarker;
struct GroupIdMarker;
pub type UserId = Id<UserIdMarker>;
pub type GroupId = Id<GroupIdMarker>;
//...
fn ping_user(id: UserId) {
//...
}
ping_user(GroupId::new(12345)); // This triggers an error
$ aptitude search librust- | grep -vE "^v " | wc -l
2336