ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Better error handling and better Comments

Open Guelakais opened this issue 1 year ago • 6 comments

A lot of error handling in the code is solved via if-queries, although you could also do it via match cases match cases are more idiomatic. There are still parts of the code that I don't quite understand. I have tried to comment everything I understand as much as possible.

Guelakais avatar Jun 24 '24 18:06 Guelakais

@Guelakais thanks for your PR. I don't like doing matches on booleans, it actually makes the code less readable. Could you just keep the comments? Thanks.

I don't like that either. However, I am more of the opinion that an error-enum should be introduced anyway, which covers error handling better. The matches somehow serve as an aid to my thinking. A suggestion: If I haven't figured it out by Wednesday evening, I'll rebuild the entire PR clean and with comments only. Until then, we can also see whether the other PRs are running better.

Guelakais avatar Jun 24 '24 19:06 Guelakais

@Guelakais I'm not going to approve a PR that has code similar to this:

    fn clone(&self) -> Self {
        let mut seq = Self::default();
        match T::sequence_copy(self, &mut seq) {
            true => seq,
            _ => panic!("Cloning Sequence failed"),
        }
    }

it just does not make sense, plus there's no way to change the definition of this function because it's part of the Clone trait, you can't change it and expect to continue working. All the functions you've changed are functions defined in their respective traits, so you can't return an error-enum if it's not part of the function signature in the trait.

esteve avatar Jun 24 '24 19:06 esteve

@Guelakais I'm not going to approve a PR that has code similar to this:

    fn clone(&self) -> Self {
        let mut seq = Self::default();
        match T::sequence_copy(self, &mut seq) {
            true => seq,
            _ => panic!("Cloning Sequence failed"),
        }
    }

it just does not make sense, plus there's no way to change the definition of this function because it's part of the Clone trait, you can't change it and expect to continue working. All the functions you've changed are functions defined in their respective traits, so you can't return an error-enum if it's not part of the function signature in the trait.

Ok,

Guelakais avatar Jun 24 '24 19:06 Guelakais

I have finally learnt how to remove git commits from my history. That makes a lot of things easier.

Guelakais avatar Jun 24 '24 19:06 Guelakais

@Guelakais I'm moving this PR back to draft, let us know when you're done making changes and we'll review it.

esteve avatar Jun 26 '24 08:06 esteve

Yes, no, it's fine. I'm done with that so far.

Guelakais avatar Jun 26 '24 18:06 Guelakais

@Guelakais are you still interested in getting this PR merged? Could you please address @maspe36 's feedback? Thanks.

esteve avatar Aug 12 '24 11:08 esteve