Skip to content

Instantly share code, notes, and snippets.

View BoxyUwU's full-sized avatar

Boxy BoxyUwU

View GitHub Profile
public static class ParticleManager
{
const int InitialPoolCapacity = 32;
public static ulong EndIndex = 0;
public static Particle[] Particles = new Particle[InitialPoolCapacity * 64];
public static int CreateParticle(string texture, float x = 0, float y = 0, float deltaRotation = 0, float velocity = 0, float scale = 1, float depth = 1, float transparency = 0, float rotation = 0)
{
internal class AStarPos
{
public int X;
public int Y;
public int G = int.MaxValue;
public int F = int.MaxValue;
public AStarPos CameFrom;
}
public class AStar
pub fn delete_entites(mut all_storages: AllStoragesViewMut) {
let mut to_kill = vec![];
all_storages.run(|healths: View<Health>,| {
for (id, (health)) in (&healths).iter().with_id() {
if health.0 < 0 {
to_kill.push(id);
}
}
});
fn main() {
let mut my_vec = vec![0, 1, 2, 3, 4, 5];
let mut my_iter = MyIterator::new(&mut my_vec);
// this prints out (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, None), None
while let Some((ref mut left, ref mut right)) = my_iter.next() {
println!("{:?}, {:?}", left, right);
}
}
fn main() {
// This wont work if the T for Wrap::<T> comes from a generic
match (Wrap::<&str>::new()).status() {
Status::Owned => println!("Owned"),
Status::Shared => println!("Shared"),
Status::Exclusive => println!("Exclusive"),
}
}
enum Status {
fn testttt() {
let mut archetype = Archetype::new::<(u32, u64)>();
archetype.add((10_u32, 12_u64)).unwrap();
archetype.add((15_u32, 14_u64)).unwrap();
archetype.add((20_u32, 16_u64)).unwrap();
let mut query_borrow = QueryBorrow::<'_, (&mut u32, &u64)> {
lock_guards: vec![
RwLockEitherGuard::WriteGuard(archetype.data.get_mut::<Vec<u32>>().unwrap().guard),
RwLockEitherGuard::ReadGuard(archetype.data.get::<Vec<u64>>().unwrap().guard),
test recorder::tests::unsoundness ... error: Undefined Behavior: constructing invalid value: encountered a dangling reference (use-after-free)
--> metrics/src/recorder/mod.rs:264:17
|
264 | dbg!(self.0);
| ^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free)
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE on thread `recorder::tests`:
= note: inside `<recorder::tests::unsoundness::Foo<'_> as recorder::Recorder>::describe_counter` at /home/boxy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:364:13: 364:16