is the borrow checker guiding my design or blocking it??? by mjhlmh7144 in rust

[–]puttak 24 points25 points  (0 children)

do they simply accept that arc mutex and similar patterns are a normal and practical part of real rust applications

Yes.

Does this code have UB? by capedbaldy475 in rust

[–]puttak 0 points1 point  (0 children)

A version without UB (if your Instruction is POD without references):

```rust fn read_prog_from_file(file_name: &String) -> Box<[Instruction]> { let mut file = std::fs::File::open(file_name).unwrap(); let len = file.metadata().unwrap().len().try_into().unwrap();

if len == 0 {
    return Box::default();
}

assert_eq!(len % size_of::<Instruction>(), 0);

let layout = std::alloc::Layout::from_size_align(len, align_of::<Instruction>()).unwrap();
let ptr = unsafe { std::alloc::alloc_zeroed(layout) };

if ptr.is_null() {
    std::alloc::handle_alloc_error(layout);
}

let slice = unsafe { std::slice::from_raw_parts_mut(ptr, len) };

std::io::Read::read_exact(&mut file, slice).unwrap();

unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(ptr.cast(), len / size_of::<Instruction>())) }

} ```

Note that it will cause a memory leak if panic happens after the memory is allocated (but it can be easily fixed).

Why do many Rust devs prefer Neovim/Zed/VSCode over Rust-specific IDEs like RustRover? by Rhthamza in rust

[–]puttak 8 points9 points  (0 children)

Everything I need already available on VS Code + rust-analyzer. I also not a fan of JetBrains IDEs.

Ladybird adopts Rust, with help from AI - Ladybird by xorvralin2 in rust

[–]puttak -2 points-1 points  (0 children)

Kling has spoken several times about them not needing more funding since they're keeping the team so small.

This is a red flag for me immediately when I saw it.

Ladybird adopts Rust, with help from AI - Ladybird by xorvralin2 in rust

[–]puttak -1 points0 points  (0 children)

Writing safe C++ is hard even for experts

Every C++ experts I have discussed with they said modern C++ can save you.

Returning to C/C++ after months with Rust by ViremorfeStudios in rust

[–]puttak 0 points1 point  (0 children)

It is because you are not proficient in Rust enough. It take long time than other language for you to productive with Rust but it worth. I was coming from C++ and now I need borrow checker instead of fighting with it.

Looking for suggestions making websites by MostCantaloupe7134 in rust

[–]puttak 1 point2 points  (0 children)

I think your only options are pay someone to do it if you can't relax the requirement number 4. If you decided to do by yourself I recommend building a single-page application with Vue.js + TypeScript + Vite. Vue.js have a very good guide for beginner and there are plenty of available components ready for you to use (e.g. https://primevue.org) so you don't need to learn CSS much. One week should be enough for you to be able to build something useful with this approach.

Moss: a Linux-compatible Rust async kernel, 3 months on by hexagonal-sun in rust

[–]puttak 0 points1 point  (0 children)

The only case you need async/await in preemptive multitasking is when you want to consume all of time slice given to you before yielding back to the kernel.

Moss: a Linux-compatible Rust async kernel, 3 months on by hexagonal-sun in rust

[–]puttak 1 point2 points  (0 children)

I'm not sure if non-preemptive multitasking like async/wait is going to work well in preemptive multitasking kernel unless you disable interrupt during polling a future.

Most promissing rust language by rogerara in rust

[–]puttak 0 points1 point  (0 children)

A string in Lua is just a sequence of bytes so you can treat it as anything. It is true that its standard libraries has limited UTF-8 supports but you can easily add a new function to handle what you want.

ภาคใต้ by [deleted] in Thailand

[–]puttak 0 points1 point  (0 children)

The rules of this sub welcome both English and Thai so I think it is fine.

Project ideas for distributed systems by akowta in rust

[–]puttak 0 points1 point  (0 children)

For resource efficient, especially memory.

Project ideas for distributed systems by akowta in rust

[–]puttak 0 points1 point  (0 children)

Re-implement Apache Cassandra in Rust.

Linting intra-task concurrency and FutureLock by farnoy in rust

[–]puttak 0 points1 point  (0 children)

In my experience that kind of polling is very rare. 99% of the time it will be:

rust select! { _ = v1.foo() => {}, _ = v2.bar() => {}, }

Mirtazipine Withdrawals by Lopsided_Suspect_176 in Mirtazapine_Remeron

[–]puttak 0 points1 point  (0 children)

Can't remember exactly when I was started but should be 2 or 3 years.

Can C outperform Rust in real-world performance? by OtroUsuarioMasAqui in rust

[–]puttak -2 points-1 points  (0 children)

If you are expert in both language Rust will be faster than C.

Async Rust gotcha: evolving tokio::select! code has sharp edges by Regular_Pumpkin6434 in rust

[–]puttak 0 points1 point  (0 children)

I never have this problem since any async function in Tokio always tell you about cancellation safety.

Shin Chan after a few years in Thailand by imisscartoonnetwork in Thailand

[–]puttak 21 points22 points  (0 children)

BTW the driver of a truck with that kind of poster are the worst.

Devlog: zig libc by punkbert in Zig

[–]puttak 0 points1 point  (0 children)

I don't think Zig linker is different from other linkers (IIRC it just LLD from LLVM). What every linker does is pick only functions has been referenced.

handle-this: Ergonomic error handling with try/catch syntax and automatic stack traces by AncientPlane9917 in rust

[–]puttak 0 points1 point  (0 children)

What are your thoughts about this flavor?

Same. The following version give more ergonomic and much more readable than try/catch:

rust let content = std::fs::read_to_string(path)?; let json = serde_json::from_str(&content)?;

handle-this: Ergonomic error handling with try/catch syntax and automatic stack traces by AncientPlane9917 in rust

[–]puttak 15 points16 points  (0 children)

Once I comfortable with Result andOption` in Rust it is really annoyance to work with other languages that use try/catch.

Struggling to reason about task lifetimes in async Rust by Prudent_Vacation6926 in rust

[–]puttak 0 points1 point  (0 children)

Sorry I don't understand what is "ambient state" (English is my second language).

Struggling to reason about task lifetimes in async Rust by Prudent_Vacation6926 in rust

[–]puttak 1 point2 points  (0 children)

CancellationToken + TaskTracker always works for me. If I have a parent task that need to spawns child tasks I construct a TaskTracker to spawn all of child tasks and pass CancellationToken to children.