Skip to content

Instantly share code, notes, and snippets.

View AlphaModder's full-sized avatar

AlphaModder

View GitHub Profile
struct TrieNode {
sib: Option<(char, usize)>,
child: Option<(char, usize)>,
terminal: bool,
}
pub struct Trie { nodes: Vec<TrieNode> }
impl Trie {
fn root(&self) -> &TrieNode { &self.nodes[0] }
@AlphaModder
AlphaModder / to_chunks.rs
Created January 6, 2022 19:22
to_chunks.rs
fn to_chunks<I: Iterator, const N: usize>(mut iter: I) -> impl Iterator<Item=[I::Item; N]> + {
std::iter::from_fn(move || {
let mut buf: [MaybeUninit<I::Item>; N] = unsafe { MaybeUninit::uninit().assume_init() };
for i in 0..N {
match iter.next() {
Some(val) => buf[i].write(val),
None => return None
};
}
Some(unsafe { (&buf as *const _ as *const [I::Item; N]).read() })
@AlphaModder
AlphaModder / PTOKEN_PRIVILEGES.cs
Last active December 23, 2021 02:49
P/Invoke definitions for PTOKEN_PRIVILEGES, for use in GetTokenInformation or AdjustTokenPrivileges
[StructLayout(LayoutKind.Sequential)]
public struct LUID
{
public int LowPart;
public int HighPart;
}
[StructLayout(LayoutKind.Sequential)]
public struct LUID_AND_ATTRIBUTES
{
error[E0560]: struct `wgpu_core::command::transfer::BufferCopyView` has no field named `offset`
--> src\backend\direct.rs:172:9
|
172 | offset: view.offset,
| ^^^^^^ `wgpu_core::command::transfer::BufferCopyView` does not have this field
|
= note: available fields are: `buffer`, `layout`
error[E0560]: struct `wgpu_core::command::transfer::BufferCopyView` has no field named `bytes_per_row`
--> src\backend\direct.rs:173:9
Updating git repository `https://github.com/gfx-rs/wgpu`
Checking wgpu v0.5.0 (C:\Users\****\Projects\Rust\wgpu-rs)
error[E0432]: unresolved import `wgt::TextureDataLayout`
--> src\lib.rs:26:80
|
26 | SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureComponentType, TextureDataLayout,
| ^^^^^^^^^^^^^^^^^ no `TextureDataLayout` in the root
error[E0412]: cannot find type `TextureDataLayout` in crate `wgt`
--> src\backend\direct.rs:885:27
use std::ops::{Deref, DerefMut};
use std::sync::atomic::{AtomicUsize, Ordering};
const EMPTY: usize = 0;
const FULL: usize = 1;
const IN_USE: usize = 2;
pub struct ResourceCell<T: Send> {
status: AtomicUsize,
resource: UnsafeCell<Option<T>>,
use futures::prelude::*;
use futures::task::{Context, Waker};
use futures::channel::mpsc;
use std::ops::{Deref, DerefMut};
use std::sync::{Mutex, MutexGuard, PoisonError, TryLockError};
pub struct AsyncMutex<T> {
inner: Mutex<(T, mpsc::UnboundedReceiver<Waker>)>,
send: mpsc::UnboundedSender<Waker>,
public class SomethingGeneric<T> : SomethingNonGeneric
{
public void DoSomething(T parameter);
}
public interface SomethingNonGeneric { }
public class SomethingStorage
{
private void addFaviconToStatusResponse(ServerStatusResponse response)
{
File var2 = this.getFile("server-icon.png");
if (var2.isFile())
{
ByteBuf var3 = Unpooled.buffer();
try
{
package net.minecraft.world.chunk;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;