-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The DeviceId type alias is hard to use. #143
Comments
The thing is, I mainly did this for
This is purely from wanting to store it, not from moving it into a struct defined in Ruma, right?
Wrapping a
That's what we had on master previously (though never in a released version). You probably didn't notice because none of the types in the other library crates ever used the borrowed version. I undid that in #131 because it didn't turn out to be a very nice solution at all – it is not at all common to use What makes you dislike |
Depends what you mean by that. Some Ruma structs now take a
Just that it requires more transformations on the client side than what we had before, e.g. if we want to store a device id we need to be aware of the fact that we need to box it. Seeing I understand that there isn't much difference between the need to box stuff now and between the need to clone a string like we had before, and if I want to hide the fact that it's a It isn't a huge friction point feel free to close this if you don't think that this is worthwhile. |
Yeah, the plan was to reintroduce
I've tried making
Unfortunately I don't see a good way of allowing
If you can come up with a good name I'm totally up to including such an alias in ruma-identifiers.
I always appreciate feedback like this, so I won't just close it :) |
Yes you did, @DevinR528 adopted the PR to use it, so as I said it isn't that much different to the
It seems that I can't, |
Same for
Yeah if we could have it and it was a convention (or we'd try to make it one) that would be kind of nice. I doubt Rust will ever allow this, though. Non-ascii idents also seem better in any way (in addition to still not being stable). |
Could we use a lower case identifier for the |
You mean snake_case, as in |
I don't know, neither looks particularly good to me. |
@poljar What's your current opinion on this after having |
An alias would be nice but I think it's fine as is as well. |
Okay, what about |
Futures went the other way with BoxFuture. I think I'm fine BoxDeviceId as well as DeviceIdBox. |
Added the type aliases in a842c5c. |
I feel like using DeviceId isn't as nice as it used to be now that DeviceId is a type alias over str instead of String. I think we only had a couple of friction points in the matrix-rust-sdk where we wanted to use &DeviceId, now we have plenty of places where we need to box the device id.
I know this isn't really important for the matrix-rust-sdk public API since we can hide it, but investing some time into a wrapper type for this might make Ruma nicer in general for everyone.
Perhaps wrapping a Cow might work, or the unicase case (🥁) mentioned over here sounds nice as well.
The text was updated successfully, but these errors were encountered: