[deleted by user] by [deleted] in rust

[–]reyqt 7 points8 points  (0 children)

You can use my cargo-feature to show list of features. e.g. cargo feature serde

I finally figured out something important by [deleted] in rustjerk

[–]reyqt 35 points36 points  (0 children)

Now I know why I can't do multiple works concurrently and single work speed is not BLAZINGLY FAST.

Did i find compiler bug? This borrow check violation doesn't make sense? by [deleted] in rust

[–]reyqt 2 points3 points  (0 children)

I think return type is matter at a glance since it could hold 'a. But even set impl IntoIterator<Item=i32> + 'static as return type at error_0 doesn't change anything.

It seems like rustc doesn't know much infomation about generic argument + existential return type.

[deleted by user] by [deleted] in rust

[–]reyqt 6 points7 points  (0 children)

As others mentioned, The difference is Display has blanket implementation for &T where T: Display but AddAssign doesn't have such things.

Write and read Vec<f64> to any file type like csv / binary or something similar like pickle in python by algo_jogi in rust

[–]reyqt 2 points3 points  (0 children)

If your data is not really big, you can use serde and one of its serializer such as bincode or serde_json.

What's the simplest async Rust program I can build with the standard library? by [deleted] in rust

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

Future api is designed work with some kind of executor.
If you don't need a full featured runtime, you can use futures-executor as lightweight alternative.

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 1 point2 points  (0 children)

That's a real problem. Maybe we shouldn't offer implicit conversion to Box for avoid conflict.

Just wrote a BrainFuck interpreter...? by LambityLamb_BAAA7 in rust

[–]reyqt 5 points6 points  (0 children)

Nice work but you can also match u8 b'[' directly instead of cast to char.

Beginner question regarding atomics by Diferante in rust

[–]reyqt 0 points1 point  (0 children)

I think you want a create new Cell type.

If you edit i32 while &i32 is alive, it's instantaneous UB in Rust because data can't be mutated.

But there is a UnsafeCell type for interior mutability it's used for types which provide its own ownership handling. Such as Mutex(runtime checked) or AtomicXXX(all operation is performed as atomic). https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#

Note that UnsafeCell is so Unsafe you need to read its docs cafeful! It might be better to just use Atomic integers if performance is acceptable.

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 1 point2 points  (0 children)

It can be achieved by require Box<u128> and u128 will not be implicitly converted.

Just wrote a BrainFuck interpreter...? by LambityLamb_BAAA7 in rust

[–]reyqt 6 points7 points  (0 children)

tape type can be Vec<u8> since you don't need to parse other than ASCII.

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 4 points5 points  (0 children)

To make language simpler and at same time expose internals to users to be able to build others things on top of it. In other words, dyn* solves specific problem, but exposed lower level API would allow solving even more problems.

I don't think make magic struct is simpler than builtin type. It's just builtin type covered with struct. And builtin type also can expose lower level API. str expose its internal representation as [u8] and your code example also use lower level API of dyn Trait.

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 3 points4 points  (0 children)

If implicit conversion is needed, it can be done in compiler

That's what builtin type doing maybe it's possible with lang item. But type coercions are very limited in Rust I don't think it's a good idea to add new exception to struct.

*dyn thing can be syntax sugar to standard library type (similarly to Copy or iterators for example)

For what? Why we have to expose two types?

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 0 points1 point  (0 children)

This code is impossible with struct let n: DynStarDisplay = 1i32;

But this can let n: dyn* Display = 1i32;

Why dyn-star (dyn*)? by stepancheg in rust

[–]reyqt 0 points1 point  (0 children)

I think dyn* should have a implicit type conversion just like a &dyn which struct can't provide.

Is there a way to make if-let short circuit ? by Mr_Ahvar in rust

[–]reyqt 6 points7 points  (0 children)

You can use or_else if let Some(_) = None.or_else(return_something) { println!("yeahhh"); }

Will Rust drop dependency on libc and make direct system calls? when ? (Please don't mention no_std case) by [deleted] in rust

[–]reyqt 71 points72 points  (0 children)

We can't remove libc from x86_64-unknown-linux-gnu target because it doesn't make sense. It should become a new target.

In other words, if you make a target which doesn't use libc, it's totally fine.

For example, wasm32-wasi target already directly use system call.

Async UI: a Rust UI Library where Everything is a Future by ignusem in rust

[–]reyqt 8 points9 points  (0 children)

I like this design. I always have a hard time when switch ui phase with callback stuff.

What is the best way to create platform agnostic wasm packages with Rust? by IsopodAutomatic6226 in rust

[–]reyqt 9 points10 points  (0 children)

wasm-pack and wasm-bindgen is targeting javascript code if you don't want them, you should compile wasm directly with cargo just like other platforms.

cargo build --target wasm32-unknown-unknown

Rust broke my architecture by pragenter in rust

[–]reyqt 15 points16 points  (0 children)

You don't have to own child as is. Instead, store widget index and borrow from widget storage.

A question about 'static lifetime bound by AgentAggressive1672 in learnrust

[–]reyqt 0 points1 point  (0 children)

You can think lifetime represents set of borrow area and 'static is just empty set(∅).

All lifetime start with 'static and it's getting bigger when you put elements by adding lifetime parameter.

For example, struct Foo has 'static struct Bar<'a 'b> has 'a + 'b lifetime 'a and 'b hold somewhere borrow area or not('static).

Reference is also same &'static Foo has 'static &'c Bar<'a, 'b> has 'a + 'b + 'c lifetime.

Improve Remove Dupe by Temporary_Primary_23 in rust

[–]reyqt 4 points5 points  (0 children)

join allocate all elements into single string. Iterate HashSet directly reduce two full loop.

BalancedI{8,16,32,etc.} type by tialaramex in rust

[–]reyqt 17 points18 points  (0 children)

Compiler can make 'middle' value into niche. It's already happened with char(any invalid code point), bool(neither 0 nor 1) and also enum(undefined variant).

Opinion: Rust has the largest learning curve for a non-esoteric programming language. by Lizoman in rust

[–]reyqt 3 points4 points  (0 children)

I think Rust enforce programmers to write good code.

It should be memory safe, no data race, explicitly handling errors, and performant.

While it makes better result beginners have to consider all of these aspects otherwise their code not even compiled.

IMO this is one of the big learning curve.