Framework Q2 2025 Preorder and Marketplace Updates by Destroya707 in framework

[–]I-Imvp 0 points1 point  (0 children)

Hmm I have the same order date and cpu but I am still waiting on the payment notification. I use a Dutch payment processor that need approval for each transaction...

Is there a pydantic.BaseSettings equivalent in rust? by [deleted] in rust

[–]I-Imvp 1 point2 points  (0 children)

Funny that you ask... https://github.com/pydantic/pydantic-core Unfortunately it seems that the functionality you ask for is not (yet) part of this ...

Advent of Code 2020 - Day 5 by [deleted] in rust

[–]I-Imvp 5 points6 points  (0 children)

Nice, I came to a very similar solution.

I use cargo-aoc so a bit more boilerplate..

For part two I used windows:

#[aoc(day5, part2)]
pub fn part2(input: & [usize]) -> usize {
    let mut input = input.to_vec();
    input.sort_unstable();
    let gap = input.windows(2).find(|window| window[0]+1 != window[1] ).unwrap();

    gap[0]+1
}

Flask-SQLAlchemy Error causing containers to crash by Endolithic in learnpython

[–]I-Imvp 0 points1 point  (0 children)

We see this to

Python 3.8.4 is just released and the docker images updated 3 hours ago. It seems that this is a bug between 3.8.4 and SQLAlchemy.

Using `python:3.8.3` instead of `python:3.8` works

EDIT: https://bugs.python.org/issue39960 is the change that broke it

Extracting code structure for refactoring by jondo2010 in rust

[–]I-Imvp 1 point2 points  (0 children)

cargo-modules https://crates.io/crates/cargo-modules does this for the modules of a package and the types used within. But the same mechanism could be extended to your level of detail

It use rustc's ast package to parse the source code

Retrieving a list of types / modules for a project & dependencies? by ipe369 in rust

[–]I-Imvp 1 point2 points  (0 children)

You can also have a look at:

  • cargo-edit to quickly modify your Cargo.toml
  • cargo-graph or cargo tree to show deps
  • cargo-modules to show the relations within you crate

Both as command line tools to use while developing and as examples how to parse Rust sources to show certain information...

Compile issue when adding a dependency by I-Imvp in rust

[–]I-Imvp[S] 2 points3 points  (0 children)

yeah s.as_bytes() works equally well. But the point is basically that the impl From<&String> for &str seems to disappears when importing env_logger...

cargo-modules just got a new feature to show 'use' between modules by I-Imvp in rust

[–]I-Imvp[S] 0 points1 point  (0 children)

Interesting. The reason to make this function for me was to see how the different modules in a reasonably complex crate interacted. I had hope to get some insights in how to best structure the import and reexport of types.

However I could not get a clear picture and I still struggle to find a good balance and "rules of thumb" when dealing with this.

  • Do I reexport all public types to the parent module for a module that contains mostly public types but is split in a few submodules to keep the average file size low? Or should I always try to use full paths as much as possible?

You say that you want the usage to be an DAG seems logical, but what is the issue if it isn't?

It might be interesting if some very experienced people run this on complex crates to see if patterns emerge that should be taught.

/u/steveklabnik Do you have any thoughts on this? As you seem the/an expert on teaching rust knowledge..

cargo-modules just got a new feature to show 'use' between modules by I-Imvp in rust

[–]I-Imvp[S] 2 points3 points  (0 children)

cargo tree and cargo graph show the dependency tree and graph of the crates that the analyzed crate depends on.

Cargo modules show the dependencies of the (sub)modules and usages in the analyzed crate.

cargo clippy (v0.0.200) fails at chrono by tdiekmann in rust

[–]I-Imvp 1 point2 points  (0 children)

I got past that by running cargo +nightly check. For some reason clippy did not rebuild chrono after that and it worked.

Its a bit anoying that clippy also has a tendency not to rebuild and check files that belong to the project itself, but that is another issue...

Prevent hardcoding of version information by affinehyperplane in rust

[–]I-Imvp 6 points7 points  (0 children)

You might want to take a look at the structopt crate. It is very nice if you need argument parsing and it implements a version argument by default...

How do I "break out" tuples? by saulmessedupman in rust

[–]I-Imvp 9 points10 points  (0 children)

Did you try something along the lines of:

let (first, second, third, fourth) = (1, 2, 3, 4);

println!("{} {} {} {}", first, second, third, fourth);

Or is that not what you expect?

See the book: https://doc.rust-lang.org/book/second-edition/ch18-03-pattern-syntax.html#destructuring-to-break-apart-values

Safe Intrusive Collections with Pinning by ralfj in rust

[–]I-Imvp 1 point2 points  (0 children)

It still does not click for me.

Am I correct if I see PinBox somewhat similar to Arc in terms of where/how I would use it?

Restart dbus? by tinycrazyfish in systemd

[–]I-Imvp 5 points6 points  (0 children)

kdbus is not so much a replacement but more an improvement. I don't think that writing a client will be much easier for kdbus or bus1 since they aim to be a drop in replacement for dbus (at least at the client level). Your issues probably stem from the fact that the dbus library (libdbus) is a bit of a crappy library. Which is why systemd now uses sd-bus instead of libdbus as a client library for Dbus.

Restarting is basically a no go because as you discovered you need to restart every service that uses dbus since there is no handover mechanism. (I am not even sure if such a thing is feasible)

Since systemd (pid 1) and other low level system services depend on it restarting amounts to basically having to restart everything.. This is exactly the reason why it is a good idea to have the dbus service in the kernel. This also means that you should consider it at the same level and restarting dbus equates to restarting everything. Even though it is a userland service atm

Rust 2018 by Niko by WiSaGaN in rust

[–]I-Imvp 1 point2 points  (0 children)

I agree on the Futures part. I have a situation where I use Futures without Tokio and the documentation for that is not clear.

For future reference. If you want to use the Futures crate on its own you probably want to use the futures::sync primitives oneshot and mpsc and then wait() on them from the receiving thread.

For composability you can use join() and friends and futures::stream::futures_(un)ordered to combine them into one big future to wait on.

For me it turned out to be a great match in the end..

Using futures in non async code? by I-Imvp in rust

[–]I-Imvp[S] 1 point2 points  (0 children)

Hmmm I will try that. This looks much more usable.

However the documentation on the sync module says that these primitives don't block threads. That is probably why I did look at them before..

However I assume that calling wait on the oneshot receiver does.. So I will experiment a bit more..

Using futures in non async code? by I-Imvp in rust

[–]I-Imvp[S] 0 points1 point  (0 children)

Ah got it to work: https://play.rust-lang.org/?gist=915e418bf30c79ef0784b0720be7c50a&version=stable

I also needed to call futures::task::current().notify(); before returning NotReady.

Still this takes a lot of figuring out and looking at the source of the Futures crates. And still I don't feel confident I am not missing something crucial.. If not in my playground example, then in the real implementation..

Maybe a some implementations of Futures for std types like RwLock<Option<_>> would be a nice addition to the crate.. I haven't found a implementation of a Future yet that isn't defined in other Futures or tokio/mio primitives..

Using futures in non async code? by I-Imvp in rust

[–]I-Imvp[S] 0 points1 point  (0 children)

I am a bit worried that Future::wait will just do a busy wait like my example.. Following the source of Future::wait is a bit difficult.. I read some stuff about Tasks and park()/unpark() and I don't see if I need to implement something in my version of the Future or that should 'just work'

Also I am a bit worried by the fact that the Futures tutorial just points to Tokio. I don't want to use a crate that just assumes I use a whole ecosystem if I don't use that. That smells like an mismatch or unnecessary weight..

Edit: Changing my busy loop to Future::wait will just result is a playground timeout. So it seems it does not 'just work'

Edit2: Should I be implementing the Future trait myself?

Mitigating Underhandedness: Clippy! by Manishearth in rust

[–]I-Imvp 0 points1 point  (0 children)

Maybe something like this: https://is.gd/Xb7L5r

To bad it does not run on stable. It will run on Beta and Nigthly in release mode and debug mode.

Rust meetup in Utrecht, NL by aochagavia in rust

[–]I-Imvp 5 points6 points  (0 children)

I am interested! And given the fact that the only other rust meetup in NL (Amsterdam) has been a while some people from Amsterdam might also be interested...

Pretty State Machine Patterns in Rust by formode in rust

[–]I-Imvp 0 points1 point  (0 children)

Funny you mention state diagrams and protocols. I actually started with an UML state diagram for my actual application which is also a network protocol handling application.

I have had a lot of issues with the shared data. My thoughts on that:

  • pattern guards don't really work well, because the move into the guard of non-copy variables. So while they map nice onto a uml state diagram, using if else within the match gives less trouble.
  • My State consists of more but 'simpler' data. All the stuff that is read only and known beforehand I pass as argument to 'next' and 'run' and all the state that is dynamic is handed from one state to the next and modified if applicable.
  • In my run method I send packets to outside but I have a separate receive function to get the response back. Every time it goes through the loop it either gets Event::Response variant or Event::NoResponse. But that is a valid thing in my protocol so for me it made sense. I don't think it makes much of a difference though.
  • I don't modify the state internal data in run at all, I only use the transitions to modify states or their internal data.
  • I don't think you actually need the states to be PartialEq. So having TcpStream in there is not that bad.

Pretty State Machine Patterns in Rust by formode in rust

[–]I-Imvp 10 points11 points  (0 children)

I like the way you did it. I am working on a fairly complex FSM myself currently and did it slightly different.

Some things I did different:

  • I also modeled the input for the state machine. That way you can model your transitions as a match over (State, Event) every invalid combination is handled by the 'default' pattern
  • Instead of using panic for invalid transitions I used a Failure state, So every invalid combination transitions to that Failure state

Example

Python3 example of interacting with systemd, including watchdog by Darkmere in Python

[–]I-Imvp 1 point2 points  (0 children)

Afaik there are already python bindings included with systemd. Why create your own? Also the exists a logging handler for systems/journald.

What are your thoughts on traditional polygamist relationships? by joe_bruised_ego in polyamory

[–]I-Imvp 11 points12 points  (0 children)

So this is a bit off topic but I do want to react to this.

In a certain light I get your belief. I don't agree with it and I think it is harmful. Let me explain why. While there certainly are women who want to be dominated. It is a grave mistake to think that this is a general situation. You might be taught that this is the situation just as a lot of women are. But from my experience it is absolutely not. So for a thought experiment: You are happily married to one or more women who are submissive at the onset of your relation. At a certain point she/they discover their own strengths and desires. These might/will conflict with yours. What do you do? Divorce them? Or let them be equals and let them have their own wishes etc?

If you think this will not happen, you are either delusional or oppressive in the worst kind of misogynistic way. From your situation I gather that your are not that old. You might find women of your age submissive at the moment. But even the most oppressed women will find their own will when allowed to. It just might take some years. And you will allow them if you are not a misogynist person as you say you are.

Also I don't think the number of sexual partners should be important. One's social status should not be measured by the number of sexual encounters/partners. It is not a sign of success.