EbTech / rust-algorithms

Common data structures and algorithms in Rust
MIT License
3.77k stars 220 forks source link

Document panics #3

Closed NilSet closed 7 years ago

NilSet commented 7 years ago

The doc comments should mention potential panics on inputs, such as an out of bounds find or merge on DisjointSets

EbTech commented 7 years ago

I added some documentation regarding panics. It's still not perfectly airtight; for example, a client can violate invariants by mutating public members. While a library should properly encapsulate everything, I'm not sure if contest programmers would want that when it's important to be able to hack things up quickly.

NilSet commented 7 years ago

I agree that being fully encapsulated is counterproductive here. The panic docs are going to be a good help for knowing what you are hacking on I think.