Skip to content

refactor: modularize files and refactor existing implementations - #438

Open
alejandro-vaz wants to merge 8 commits into
servo:v2from
alejandro-vaz:modularization
Open

refactor: modularize files and refactor existing implementations#438
alejandro-vaz wants to merge 8 commits into
servo:v2from
alejandro-vaz:modularization

Conversation

@alejandro-vaz

@alejandro-vaz alejandro-vaz commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

this PR is the preliminary implementation of #427

scope of this PR

this PR aims to refactor the codebase to make it navigable

it starts to split the old 3k LOC lib.rs into small submodules based on abstraction boundaries:

  • allocationerror.rs => error types
  • bytes.rs => functionality provided by the bytes crate, gated by a cfg
  • comparisons.rs => Eq and Ord, total and partial
  • lib.rs => remaining not-yet-refactored code
  • mallocsizeof.rs => MallocSizeOf work gated behind a cfg
  • rawsmallvec.rs => already implemented by @zachs18 on Make RawSmallVec (and its fields) public only under feature = "internals". (v2) #348
  • references.rs => asref, borrow, deref. for const and mut references
  • serde.rs => serde's serialize and deserialize gated behind a cfg
  • std.rs => standard library implementations. currently, only std::io::Write
  • taggedlen.rs => TaggedLen and its implementation
  • tests.rs => tests, already present before

other changes

  • renamed CollectionAllocErr to AllocationError
  • removed an is_zst<T>() helper which can be inlined by a simple comparison
  • changes rustfmt.toml a bit to group imports and removed the use of the vec! macro so the formatter didn't get confused about whether it was referencing the vec module or the vec! macro

Note

documentation doesn't build properly, see #439

Note

experimented a bit with rustfmt.toml, should make files easier to read now

@alejandro-vaz
alejandro-vaz marked this pull request as ready for review August 24, 2026 12:29
@alejandro-vaz alejandro-vaz mentioned this pull request Aug 24, 2026
1 task
Comment thread rustfmt.toml
Comment on lines +6 to +7
blank_lines_lower_bound = 0
blank_lines_upper_bound = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think removing all blank lines improves readability; I think it makes it worse. Also note that servo/servo doesn't do this (example)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair

then probably 0 for lower bound and 1 for upper I guess. 2+ looks weird to me

did it out of inertia, didn't think much about it, I'll fix it tomorrow

code looks weird though now that you're saying it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants