Add `getters::getlocale`
Add a way to get the current active locale by passing in a null pointer
to the C setlocale function, which is documented to be the way to
query the locale; without this, there is no way for users of this
library to query the current locale.
I added this functionality because it is useful, at least, for debugging; for example, an issue I am having with setlocale() :)
BTW you can ignore the CI failure for musl. I am meaning to fix it, but haven't yet figured out how (#99).
Hey @timotheos-firestone, gentle ping ;) I haven't done anything about the musl CI yet, but this PR doesn't depend on musl, so it can be merged regardless. Would you like to finish this?
I might be in the mood of taking this over. Would you mind if I change the return type of setlocale to Result<(), ()>?
I can add tests, just need some guidance as to what needs to be done
Would you mind if I change the return type of setlocale to Result<(), ()>?
I'm very hesitant to do that because this loses the information that the underlying C function returns. But clearly you have a reason to change the type; can you share the thinking behind that?
I can add tests, just need some guidance as to what needs to be done
The smoke test I had in mind goes something like this:
let original_from_getlocale = getlocale();
let original_from_setlocale = setlocale(LC_ALL, "en_US.UTF-8");
assert_eq!(original_from_getlocale, original_from_setlocale);
let en_us_utf8 = setlocale(LC_ALL, original_from_getlocale);
assert_eq!(en_us_utf8, "en_US.UTF-8");
let restored = getlocale();
assert_eq!(restored, original_from_getlocale);
it has to be a separate integration test. We can't put it into tests/integration.rs because the tests there rely on the shared environment where the locale doesn't change.