causal-agent / scraper

HTML parsing and querying with CSS selectors
https://docs.rs/scraper
ISC License
1.81k stars 100 forks source link

refactor: Make `selectors` field private #87

Closed volsa closed 1 year ago

volsa commented 1 year ago

A little pet peeve I came across when using this library (it's awesome btw!) was rust-analyzer suggesting often times the initialisation of the Selector struct manually since the selectors field is public. This PR changes the visibility from

pub struct Selector {
    pub selectors: SmallVec<[parser::Selector<Simple>; 1]>,
}

to

pub struct Selector {
    selectors: SmallVec<[parser::Selector<Simple>; 1]>,
}

No breaking changes are introduced as the selectors field isn't used directly anywhere outside the module anyways.

teymour-aldridge commented 1 year ago

Thanks!

No breaking changes are introduced as the selectors field isn't used directly anywhere outside the module anyways.

This is technically a breaking change (because the Selectors struct is public, and could previously be constructed outside the module), which is fine (we'll just bump from v0.13 to v0.14 in the next release).

volsa commented 1 year ago

This is technically a breaking change (because the Selectors struct is public, and could previously be constructed outside the module), which is fine (we'll just bump from v0.13 to v0.14 in the next release).

Oh that's true, I just assumed everyone's using the parse function as documented. Anyhow, thanks for merging and maintaining this awesome library!

cfvescovo commented 1 year ago

Thank you for your contribution!