rust-analyzer / expect-test

Minimalistic snapshot testing for Rust.
Apache License 2.0
248 stars 22 forks source link

Expose data stored in `Expect` as true public API #14

Closed Veetaha closed 2 years ago

Veetaha commented 3 years ago

As for now the data: &'static str property of Expect struct is marked as doc(hidden), which means that it is intended to be private.

https://github.com/rust-analyzer/expect-test/blob/f0cd358a1c4bc876bb778d7b769e455052f6171f/src/lib.rs#L198-L205

However, I have a use case where I need to access the data of the snapshot from expect to do further assertions. It is not possible to workaround this by storing the data in a separate variable:

let data = "...";
let expect = expect![[data]];

just because expect! macro accepts a literal token, not an expr.

I suggest exposing a public getter for data, @matklad wdyt?

matklad commented 3 years ago

sgtm!

Let's expose

fn data(self) -> &str