I'm trying to save my users some pain, suffering and confusion
in Java I'd do this with ASM/bytecode manipulation libs. doesn't quite work in Rust tho. ;)
centril
Soni: it is interesting as a consistency fix, but I personally don't have uses for this.
Soni
hmm I guess I could also try something with macros for the time being... are macros truly hygienic if e.g. they make a static and a trait impl? (at least then I can #[doc(hidden)] the stuff) it won't be the nicest thing in the world (it won't be nice at all) but might work??? idk
Mutabah
Iirc, if you have multiple invocations of a macro that creates a static, there will be multiple statics
Soni
oh ok, so they are hygienic, I guess
lukaramu joined the channel
as long as it doesn't error about two statics of the same name
Mutabah: The associated static in their link isn't generic.
Soni
the associated static uses Self
which might be e.g. VecEvent<T>
Mutabah
nox: Point
Soni
I feel kinda dizzy bbl
centril
I think a problem with associated statics is that it would __require__ every impl to have a static, which the impl might not need and would needlessly pay for
chordowl joined the channel
lukaramu has quit
oln joined the channel
JoshTriplett joined the channel
JoshTriplett has left the channel
Ericson2314_ joined the channel
Soni
I'm back
centril: why associated consts ok but not associated statics?
if static storage space is an issue, it can be made lazily heap-allocated
in my case I do need every impl to have a static tho, so it fits perfectly
rkruppe joined the channel
nox
"Be made lazily heap-allocated" = use lazy_static
Soni
... ok may I have an op
idk who's an op here
centril
Soni: this is only _a_ problem... I'm not saying that it is make-or-break
Soni
centril: this *can* be a problem, but if the *trait author* wants an optional static they can make it lazily heap-allocated and then the static is only the size of a pointer
my use case is the canonical use case for associated statics and can someone please ban nox already
centril
Soni: sure, I understand this
nox
Soni: What the hell are you saying?
I literally show you you don't need any associated statics for your use case and you want me banned?
centril
Soni: no one is going to ban nox...
If you have an issue with a CoC violation, talk to a moderator, and don't ask for bans here..
But I'm confident there hasn't been a CoC violation.
Soni
they keep derailing the conversation and they don't wanna listen to anything I have to say
also, I did ask for an op
eijebong joined the channel
nox
I am not derailing the conversation when I show you that your use case is not "the canonical use case for associated statics", when I demonstrate you don't actually need "associated statics", either for performances or to avoid Hash uses or whatever.
Soni
anyone knows if the playground does lazy static?
centril
cc mbrubeck
djc
Soni: it also looks to me like you're not listening very well to what nox has to say
centril
or Manishearth
Soni
nox: ok let me try it 1 sec
nox
Soni: If you write `extern crate …` it autocompletes the included crates, lazy_static is part of them.
Yeah, if you write it in a way that it doesn't work, it will not work.
Your issue isn't about associated statics, but about associated generics, now.
Manishearth
Soni: no, I am not banning nox
Soni: every single conversation between you and nox, and in general between you and others, is you asking for language features, nox providing alternates or asking for clarification, and you ignoring it
mbrubeck
Hey folks, if someone's answer to a technical question doesn't seem helpful, please either ignore it or ask for clarification; don't treat it as an attack (or as centril said, talk to a mod). Likewise if someone isn't receptive to your help, please feel free to just drop it.
nox
There is not even an implementation of TestTrait in your snippet.
Soni
nox: well ofc there isn't, why would I type the impls if it already doesn't even compile
the idea is that you'd do "impl TestTrait for AType" and "impl TestTrait for BType" and they'd have independent (associated) statics
If Rust had associated statics, it would still not compile.
Just like generic statics don't currently compile.
mbrubeck
"This RFC was originally accepted before RFC 246 introduced the distinction between const and static items. The text has been updated to clarify that associated consts will be added rather than statics" but doesn't give more details
Manishearth
Yeah -- there's nothing in Rust preventing us from adding associated statics, however there hasn't been much clear impetus either