Giter Club home page Giter Club logo

Comments (7)

whitequark avatar whitequark commented on June 4, 2024

Sure. Do you think you could play with rustfmt's options to get an output very close to the current one? Then I'll merge that and reformat the rest.

from smoltcp.

podhrmic avatar podhrmic commented on June 4, 2024

I ll give it a try. I think the main difference is the alignment - i.e. this is what is in smoltcp now:

    /// Return the header length.
    /// The result depends on the value of the message type field.
    pub fn header_len(&self) -> usize {
        match self.msg_type() {
            Message::EchoRequest    => field::ECHO_SEQNO.end,
            Message::EchoReply      => field::ECHO_SEQNO.end,
            Message::DstUnreachable => field::UNUSED.end,
            _ => field::CHECKSUM.end // make a conservative assumption
        }
    }

And this is after rustfmt with default settings:

    /// Return the header length.
    /// The result depends on the value of the message type field.
    pub fn header_len(&self) -> usize {
        match self.msg_type() {
            Message::EchoRequest => field::ECHO_SEQNO.end,
            Message::EchoReply => field::ECHO_SEQNO.end,
            Message::DstUnreachable => field::UNUSED.end,
            _ => field::CHECKSUM.end, // make a conservative assumption
        }
    }

So I am not sure how much you care about the right alignment?

from smoltcp.

whitequark avatar whitequark commented on June 4, 2024

To be honest I find that it helps readability a lot.

from smoltcp.

podhrmic avatar podhrmic commented on June 4, 2024

After poking around it looks like there is no setting for rustfmt that would keep the LHS => RHS alignment as you have it. Apparently it is a discouraged style for Rust.

So the question is - do you prefer to keep your current formatting even though it means no automatic format checking, or do you want to switch to the format mentioned above?

from smoltcp.

whitequark avatar whitequark commented on June 4, 2024

Let's keep it, but just so that your work doesn't go nowhere, please post your rustfmt config here. If we ever switch to using rustfmt I'll make use of it.

from smoltcp.

podhrmic avatar podhrmic commented on June 4, 2024

OK. Place rustfmt.toml in the root dir of the project.

The contents are simple and can be further tuned:

attributes_on_same_line_as_field = false
attributes_on_same_line_as_variant = false
struct_field_align_threshold = 20
tab_spaces = 4

See https://github.com/rust-lang-nursery/rustfmt for details

from smoltcp.

whitequark avatar whitequark commented on June 4, 2024

I looked at the diff produced by rustfmt. It is 11937 line long and readability suffers, particularly badly with tests. Thank you for your work but I don't think I'm going to use rustfmt for my projects.

from smoltcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.