FractalFir / tmf

Tight Model format is an experimental lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.
MIT License
100 stars 6 forks source link

Use unified methods to read primitives from Read #13

Closed nicopap closed 1 year ago

nicopap commented 1 year ago

This removes a bit of the boilerplate around reading primitives from std::io::Read.

This trims about 90 lines from the source, making it a bit more accessible.

The lines in question are also fairly tricky to read and unrelated to surrounding code, so this helps too.

Alternative

An alternative would be not to define those methods as a trait extension for Read, but rather as free functions. Then you would simply call them.

This method is not inferior to the one I chose. But trait extensions are more rusty.