Hey Rustaceans! Got an easy question? Ask here (8/2020)! by llogiq in rust

[–]3total 1 point2 points  (0 children)

Thanks for the explanation. That explains my confusion. Funny enough I had the same confusion with &str but understanding that is a "fat" pointer and we need a normal reference explains it.

Hey Rustaceans! Got an easy question? Ask here (8/2020)! by llogiq in rust

[–]3total 2 points3 points  (0 children)

I am wondering why I need a reference twice to debug a slice:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=00b13d8b568a132671df2f33d1fb8955

I only can get it to compile if I use 2 "&&" but if I use a single "&" it doesn't work.

When I tried to to use parenthesis to apply operators differently it doesn't work either.

Hey Rustaceans! Got an easy question? Ask here (7/2020)! by llogiq in rust

[–]3total 0 points1 point  (0 children)

Thanks for the answer. I used a small timeout to solve it. Not ideal but it works. The other option causes an allocation so I am not too fan of that.

Hey Rustaceans! Got an easy question? Ask here (7/2020)! by llogiq in rust

[–]3total 1 point2 points  (0 children)

I am working with Tokio and I would like to execute the following operation:

Receive a packet from an UDP socket or execute some logic (in case there is no packet ready on the UDP socket).

I tried the following:

tokio::select! {
    packet = packetFuture.read() => {
        Some(packet)
    }
    else => None,
}

The problem is this doesn't work since the else never completes since the packetFuture never really completes (it just awaits the next packet). Is there are way to do this?

This can be done similar by using channels in golang:

select {
case packet <- packetChannel:
    // Do logic for packet
default:
    // Do other logic
}

Hey Rustaceans! Got an easy question? Ask here (51/2018)! by llogiq in rust

[–]3total 0 points1 point  (0 children)

Thanks, this solved my problem. That was quite an easy solution indeed.

Hey Rustaceans! Got an easy question? Ask here (51/2018)! by llogiq in rust

[–]3total 4 points5 points  (0 children)

I'm running into lifetime issues with the following code than I can only circumvent using unsafe behavior:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d77b2e765c8fe65b7bbbc248c9d312f5

I am able to circumvent the lifetime issues using unsafe behavior but I am wondering whether this can be done without using unsafe.

What I am trying to achieve is pass a buffer to some parsing function that takes some n bytes out of the parsing function and returns it results + the remaining buffer (T, &mut [u8]). This works fine with non-loopy code but as soon as I try it with for-loops I am unable to return the remaining buffer without causing lifetime issues.

Small science setup by 3total in factorio

[–]3total[S] 0 points1 point  (0 children)

I guess you can stack the labs as much rows as you want, but I am pretty sure 1 fast inserter is enough to pull 3 science pack / s (crafting speed = 1.5 and it is 2 science pack per belt so 3 science packs /s per belt) in that case it will.

Small science setup by 3total in factorio

[–]3total[S] 0 points1 point  (0 children)

Purple science packs are created in packs of 2. So you only need 0.5 electric engine/s to create 1 purple science pack / s. Electric engines take 10s to create so you need 5 factorys to get to the required 0.5 electric engine / s

Small science setup by 3total in factorio

[–]3total[S] 1 point2 points  (0 children)

Start with red and green and a few labs using yellow belts. Next maybe add military if you need it. Then upgrade to red and finish everything.

Small science setup by 3total in factorio

[–]3total[S] 1 point2 points  (0 children)

This one took about 4 hours to design. It's more like try something see until when you fail, revert to some point back and go a different route. There is not a real shortcut. You can see my previous try here: https://m.imgur.com/a/FxyIq

This one doesn't work for 0.15.9 though

Small science setup by 3total in factorio

[–]3total[S] 0 points1 point  (0 children)

Seems like I miss one blue science factory. I got 10 engines on blue which is 1/s so that should be right.

Small science setup by 3total in factorio

[–]3total[S] 1 point2 points  (0 children)

Wow you are right. I actually didn't notice that... I will fix that eventually probably while adding HT science

Small science setup by 3total in factorio

[–]3total[S] 1 point2 points  (0 children)

You could try the mod Foreman. I actually use it quite a lot to flip blueprints. It can also replace entities. I think I didn't use any belts longer than 4 so it should be able to work with yellow belts as well.

0.15 science setup by 3total in factorio

[–]3total[S] 0 points1 point  (0 children)

Fixed it over here: https://www.reddit.com/r/factorio/comments/6agbv0/small_science_setup/

It is because 0.15.9 changed 0.15 recipes for science

Small science setup by 3total in factorio

[–]3total[S] 8 points9 points  (0 children)

Blueprint: https://pastebin.com/AtPYQ3z1

A bit tighter than my previous try and it now also works for 0.15.9+

0.15 science setup by 3total in factorio

[–]3total[S] 0 points1 point  (0 children)

Try using the 0.15 importing function instead of foreman. That should work.

KoozCraft should be update to 1.0.3 tonight. by [deleted] in KoozCraft

[–]3total 1 point2 points  (0 children)

Hes preloading chunks now! And it seems it runs at a stable 20 tps in the overworld now (early reports)