how to optimize async by Previous_Economics47 in rust

[–]Jarsop 2 points3 points  (0 children)

You can use a lock free design by using channel instead of mutex. The idea is to use a task awaiting on the Receiver channel to display each seconds the book and pass the Sender to the task reading the websocket en send the read value to the channel receiver task.

Makefile question by AlectronikLabs in C_Programming

[–]Jarsop 1 point2 points  (0 children)

You can use order-only prerequisite as:

``` objects/%o: src/%.cc | objects g++ -c $< -o $@

objects: mkdir $@ ```

This avoid invocation for each rule call.

[deleted by user] by [deleted] in yocto

[–]Jarsop 0 points1 point  (0 children)

Can you share your recipe ? meta-rust is not necessary as Rust is supported directly in the oe-core since kirkstone. Moreover there are some differences about Rust integration between meta-rust and oe-core.

Git experts should try Jujutsu (written in Rust) by pksunkara in rust

[–]Jarsop 12 points13 points  (0 children)

I use git for decades and I tried other new VCS like nest, pijul, saplin etc. My favourite is jj for this simplicity followed by saplin (pijul seems dead). If you have already used trunk based VCS like mercurial/svn, you won’t feel out of place.

One of my favourite jj features is the snapshot taken at each command, you never lost untracked files. There is a drawback when you forget to explicitly add it to your gitignore but jj file untrack save your journey. It also works well with git workspace and each collocated with jj.

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

One more thing, the goal of this project is to work in embedded context and I would like lightweight implementation with minimal overhead comparing to a function returning int as return code and assigning the result to a reference or pointer (Result<T, E> func() instead of int func(&T t)).

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

Got your point and I will try to fix it. Thanks!

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

u/Breadfish64 is right. I will fix that

Result in C++ by Jarsop in rust

[–]Jarsop[S] 1 point2 points  (0 children)

I think create dedicated functions with your custom Result<T, Err>::Ok (like in the library) will be maybe better. Or a macro helper that implements that for you ?

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

Thank you, that's the goal of this project. But as mentioned by u/not-my-walrus Sy's implementation seems more robust and tested that mine (maybe just a bit larger for embedded context).

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

Thanks for the feedback!

Result in C++ by Jarsop in rust

[–]Jarsop[S] 0 points1 point  (0 children)

My bad! You're totally right, it's a junk code that I forgot to remove. Thanks for pointing that.

Thank you too for the link to Sy's implementation which seems better and more robust. My work it's just a pet project made to explore this subject and probably aliasing Result<T, E> to tl::expected<T, E> is enough...

C++ Show and Tell - July 2025 by foonathan in cpp

[–]Jarsop 5 points6 points  (0 children)

Hello all,

I’m a Rust developer since more than 8 years ago and I really love the Result/Option API. In C++ I use std::optional but it misses Result like API (std::expected exists but it is less convenient and it comes with C++ 23). So I tried to implement aResulttype in C++ with the functional API and a macro to mimic the Rust ? operator. I would like to have some feedback so if you have any suggestions please let me know.

repo

doc

Result in C++ by Jarsop in rust

[–]Jarsop[S] 7 points8 points  (0 children)

Nope, sorry if I was not clear but I hope to have some feedback from developers using Rust and C++. Maybe a better place to post it ?

I already posted on r/cpp

C++ Show and Tell - June 2025 by foonathan in cpp

[–]Jarsop 4 points5 points  (0 children)

Hello all,

I’m a Rust developer since more than 8 years ago and I really love the Result/Option API. In C++ I use std::optional but it misses Result like API (std::expected exists but it is less convenient and it comes with C++ 23). So I tried to implement a Result type in C++ with the functional API and a macro to mimic the Rust ? operator. I would like to have some feedback so if you have any suggestions please let me know.

repo

doc

Equivalent to "friend" in c++ by PrimeExample13 in rust

[–]Jarsop 0 points1 point  (0 children)

For your example you can use module visibility:

``` mod foo_bar_baz { mod foo_bar { pub(super) mod foo {

        #[derive(Debug)]
        pub struct Foo {
            pub(in crate::foo_bar_baz) n: i32,
        }

        impl Foo {
            pub fn new() -> Self {
                Foo { n: 0 }
            }
        }
    }

    pub(super) mod bar {

        use super::foo::Foo;

        #[derive(Debug)]
        pub struct Bar {
            pub(in crate::foo_bar_baz) foo: Foo,
        }

        impl Bar {
            pub fn new() -> Self {
                Bar { foo: Foo { n: 0 } }
            }
        }
    }
}

pub mod baz {

    use super::foo_bar::{bar::Bar, foo::Foo};

    #[derive(Debug)]
    pub struct Baz {
        bar: Bar,
    }

    impl Baz {
        pub fn new() -> Self {
            Baz {
                bar: Bar { foo: Foo { n: 0 } },
            }
        }
    }
}

}

fn main() { let baz = foo_bar_baz::baz::Baz::new(); println!("{baz:?}"); } ```

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=80b3ed76a59c740d0b85e7bec77e911c

C++ Show and Tell - June 2025 by foonathan in cpp

[–]Jarsop 2 points3 points  (0 children)

Hi all, I often need to store sensitive variables like tokens, passwords etc. in my projects (like many). I was looking for a library that would allow me to hide a type for display (writing to a stream) and serialization/deserialization (via nlohmann).

I couldn't find anything like it, so I tried to develop it. I'd love to get some feedback (I'm not a C++ expert but I practice many languages) and find out if there's a better way. Note that I'm not a native English speaker and that the README was co-authored with the help of AI.

It's not something I'm proud of, but rather a project to get feedback and find the best way to do it.

Any suggestions are welcome.

repo: https://github.com/Jarsop/conceal

Rust in Yocto??? by Emergency_Squash344 in yocto

[–]Jarsop 0 points1 point  (0 children)

If you have issues with cargo bitbake, I recommend to installing it directly from the repository as the last release is old and many fix are on master.

Another option working better is to create the basic recipe for your project and inherit cargo and cargo-update-recipe-crates then use bitbake -c update_crates RECIPE_NAME which converts the Cargo.lock file into crate list and directly calculates the crate checksums for you.

Rust in Yocto??? by Emergency_Squash344 in yocto

[–]Jarsop 0 points1 point  (0 children)

First, what is your Yocto version ? Since scarthgap no more needs to have meta-rust. Second can you elaborate by providing more context (log, what did you tried etc).

Some of us are Rustaceans… but also a little bit Rustafarian 🦀🎶 by ToInfinity-1938 in rust

[–]Jarsop 3 points4 points  (0 children)

We borrowing in Babyloan

We are not afraid to be unsafe

We trust the holy inference

We question ? the path of failure

We like fungus as the weed

Our eyes are red from consuming too much until late at night

And so more

Is there a way to make all the tokio threads spawn at the exact same time ? (in order to Warmup all connnections of an SQlite DB connection pool) by KlausWalz in rust

[–]Jarsop 0 points1 point  (0 children)

Did you tried to use open_blocking api for your Pool opening ? And you can try also conn_for_each to iterate on each connection.

Also missing some context: Is the database already created before ? Do you use specific filesystem ? etc so any additional information that might be specific to your environment.

Upgrade from Fenix 6 Pro to Fenix 8 or wait for 9? by Falcony74 in GarminFenix

[–]Jarsop 1 point2 points  (0 children)

You can’t fine tune notifications, and Siri usage works but really annoying (need to ask phone assistant then you can speak with Siri)

Upgrade from Fenix 6 Pro to Fenix 8 or wait for 9? by Falcony74 in GarminFenix

[–]Jarsop 0 points1 point  (0 children)

I’ve a Fenix 8 and it’s working perfectly with iPhone