Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.tw/irclogs/ Connected with DDNet's IRC channel, Matrix room and GitHub repositories — IRC: #ddnet on Quakenet | Matrix: #ddnet-developer:matrix.org GitHub: https://github.com/ddnet
Between 2021-06-06 00:00:00Z and 2021-06-07 00:00:00Z
Avatar
I released I don't know whether teeworlds messages are garenteed to be in order.
13:57
realized*
Avatar
some are i guess
14:05
the ones that send acks
14:05
vital packages
Avatar
The server would send a packet instead of a chat message with a id and arguments, then the client would display the translated messages with those values. We would then need our own printf parser a...
Avatar
Did I tell you I absolutely hate autocompletion... Why can't it just work or not work?
15:32
This inbetween garbage annoys me so much
Avatar
you mean from mobile keyboards?
15:35
or coding? xd
Avatar
Coding
15:35
@Ryozuki you have RLS working in your vim setup, right?
Avatar
@TsFreddie did you do smth with mini screen btw? i am curious xd
Avatar
not really, haven't got time
Avatar
ah ok
Avatar
rust-analyzer works better, now I only need a 24 core machine so it's remotely performant
15:48
amazing stuff
Avatar
Avatar
Learath2
@Ryozuki you have RLS working in your vim setup, right?
RLS?
16:19
hell no
16:19
i always used rust analyzer
16:19
RLS is on the path of being replaced entirely by rust-analyzer
16:19
its abandoned i would say
16:19
everybody uses rust-analyzer
16:19
btw, rust-analyzer is considered to be one of the best implementations of a language server
16:20
among all language servers of any language
Avatar
yeah, it works much better, funny how the official extension on vscode uses rls by default and has abysmal rust-analyzer support
Avatar
use the rust-analyzer extensio
Avatar
yeah, that works much better, it's rather slow but that's my 4c/8t processor being not enough
16:21
need 24 threads to run modern autocompleters fluently
Avatar
well for me the only slow thing is when u load the first file
16:21
it has to index all
16:21
but then its ifne
16:21
It seems like we're not just a good LSP for Rust, but a good LSP overall: We're now the highest-rated VS Code plugin for programming languages! If you'd like to help us become even better, consider sponsoring us on GitHub Sponsors: https://t.co/HtltXjLWL8
Likes
351
Avatar
@Learath2 vscode still has to harness the power of treesitter highlighting, on the left normie vscode, on the right neovim with treesitter
16:29
the lens stuff on neovim are also way less invasive
16:30
xd
Avatar
1. Since the config didn't have a limit set, they could be negative, which directly caused bugs 2. If you set a min mouse distance, lets say 5, It can mathematically happen that you drag your mouse exactly so much that you hit the (0, 0) point and the if(.. < MinDistance) branch normalizes that point, which causes non restorable NaNs. It's now safe, the min distance is later in code checked to be atleast 1, i "even" just made it safe enough, so there shouldn't be any change in behaviour: h...
Avatar
how can i translate player color to RGBA (edited)
Avatar
isn't it output as hex with an additional 2 hex digits for transparency
22:43
thx
Avatar
Depends on where you are looking for it, in the console if you print numbers it will tell you r g and b values
22:44
@heinrich5991 here?
22:44
or @Ryozuki, or anyone else with rust experience really
Avatar
Avatar
Learath2
Depends on where you are looking for it, in the console if you print numbers it will tell you r g and b values
oh wow didnt notice this was added (edited)
Avatar
@Anime.pdf try to be conservative with your edits in this channel, they sort of spam irc
Avatar
@Learath2 here
Avatar
@heinrich5991 How would you go about wrapping multiple error types? I want my InternalError to be able to hold either a std::env::VarError or a reqwest::Error
Avatar
what are you writing? application or library?
Avatar
application
22:48
but it's a module that really should be just propagating it's errors upwards
Avatar
Flexible concrete Error type built on std::error::Error - dtolnay/anyhow
derive(Error) for struct and enum error types. Contribute to dtolnay/thiserror development by creating an account on GitHub.
Avatar
so well do i need to enter hex code in ColorRGBA constructor
Avatar
you can also emulate thiserror yourself with a few From implementations and an enum
Avatar
cuz r, g and b as args are not working
Avatar
@Anime.pdf no, ColorRGBA has multiple constructors, I don't think it has a hex one
Avatar
i just get white instead of blue
22:50
whenwwseeachild
Avatar
@heinrich5991 I have enum Error { InternalError, BackendError(String) } not really sure how to shove either error into an InternalError
Avatar
do you want to keep the representation or not?
22:51
you probably want to wrap it, right?
Avatar
I could do enum Error { VarError(std::env::VarError), ReqwestError(reqwest::Error), BackendError(String)} but I'd much prefer if I could have just one InternalError
22:51
I want to wrap it, so yeah, keep the representation
Avatar
do you want to avoid a dependency on anyhow?
22:53
enum Error { Internal(anyhow::Error), Backend(String) }
Avatar
Well I can use anyhow, but I'm still getting more familiar with rust so I'd prefer to also know what it does to achieve this
Avatar
anyhow uses a trait object representation (like virtual base class polymorphism). we can handcraft it though
Avatar
(I'm guessing it's a Box<dyn Error> underneath it all)
Avatar
under anyhow, yes
22:56
enum Error { Internal(Box<dyn Error>), Backend(String) } // or enum Error { Internal(InternalError), Backend(String) } enum InternalError { Var(std::env::VarError), Reqwest(reqwest::Error) }
Avatar
hm, we should be able to avoid this kind of dynamic polymorphism though, since all my error types are known in advance, no?
Avatar
that's the latter representation above
Avatar
Ah, someone should do a rfc for anonymous enums 😄
Avatar
then do impl From<std::env::VarError> for Error { fn from(e: std::env::VarError) -> Error { Error::Internal(InternalError::Var(e)) } }
22:58
and the same for the reqwest error
22:58
that enables you to use the ? operator
Avatar
Yeah already had the froms there, I was just missing the second enum
22:58
Q: How costly is rusts runtime polymorphism? About around C++?
Avatar
the runtime polymorphism works quite similar, except that the vtable pointer is stored next to the pointer instead of inside the pointed-to object
23:00
i.e. Box<dyn std::error::Error> is two pointers wide
23:00
This emoji doesn't work here because it's from a different server. Discord Nitro can solve all of that, check User Settings > Nitro for details
23:01
I'll have to use a Box<dyn Error> anyway, apparently reqwest errors don't implement the trait Clone
Avatar
I see no reason why boxing would help with that issue
23:03
thiserror helps with the enum boilerplate btw, and anyhow with the trait object boilerplate
Avatar
Hm, I guess I could drop the Clone trait from my own error type
Avatar
(a boxed reqwest error is still unclonable)
Avatar
If you want to propagate the errors upwards, you probably also want to match them, right?
23:05
is matching possible with anyhow?
Avatar
not really (a little bit)
23:06
but in practice I never ended up matching on "what library did this error originate from" (for libtw2 at least)
Avatar
It's nice that this language makes you think about errors but sometimes you just want to get on with it 😄
Avatar
Avatar
Patiga
If you want to propagate the errors upwards, you probably also want to match them, right?
ah I suppose the assumption here might be the problem then ^^
Avatar
@Learath2 take anyhow then
Avatar
I'll do the two enums, I don't need to change my code then, just need to rename a couple things
Avatar
it's really nice. it gives you the possibility to attach context
Avatar
I need to match the errors outside, is that possible with anyhow?
Avatar
not really
23:07
(you could downcast them, but it's ugly)
23:08
can you explain why it's interesting whether you get a VarError or a reqwest error from the outside?
Avatar
A VarError I can't recover from (but I'm not really sure how to cleanly die inside an async), A Reqwest error I'll just exponentially backoff
23:13
You know what, if I knew what was good for me I'd just extract all the vars at the start
Avatar
sounds good 😉
23:14
rust led me to overcomplicate stuff before, because it's suddenly in the "possible" range
Avatar
oh, is there an "idiomatic" way to do global application state in rust?
Avatar
do it as simple as possible to get it to work. is my new motto
23:14
do you want it thread-local or global?
Avatar
global
23:15
So a Arc to a hashmap is what I was thinking
Avatar
I think a lazy_static can have a mutex
23:15
a normal static can't because rust relies on posix mutexes which cannot be constructed at compile time
Avatar
I don't need a mutex, it won't change at runtime
23:16
(well not after startup)
23:17
this then, I guess?
23:18
it'll get into the standard library at some point
23:18
ah, you probably need parameters as well
23:18
this then
23:18
call get_or_init to initialize it once
Avatar
such a complex thing, what does it provide even?
Avatar
oncecell?
Avatar
thread-safe initialization
23:21
that the initialization func will only get called once
Avatar
sounds like something I don't need, at startup I have a single thread, I need to populate a hashmap from some config and some env, then all the threads just read from it
Avatar
heinrich5991
You can do that in Rust by creating your own abstraction around UnsafeCell. Say InitializeCell: use std::cell::UnsafeCell; use std::mem::MaybeUninit; use std::ops; pub struct InitializeCell<T> { inner: UnsafeCell<MaybeUninit<T>>, } unsafe impl<T> Sync for InitializeCell<T> {} impl<T> Initiali...
23:23
does that suit you? ^^
23:24
you can have the code under any license
23:25
fun, apparently I went through the same exchange with that person as with you
Avatar
Still looks quite complex, hm I'm going too fast again, concurrency is annoying enough in C++
Avatar
okay, I wouldn't consider this complex
23:29
the stuff compiles down to memcpy
Avatar
I mean complex for the trivial thing I'm doing, I can read it if I squint really hard
Avatar
so much stuff I could suggest. but I wanna go to bed :/
Avatar
go ahead, I'll figure something out 😄
Avatar
good night 🙂
Avatar
@heinrich5991 if you didn't go yet what's wrong with just a Arc<HashMap<K, V>>?
Avatar
that was actually my next suggestion
23:34
*that would actually have been
23:34
I think the quic library from cloudflare does it
23:34
it's an atomic instruction per clone, can be fine
23:34
probably will be fine
Avatar
Ah I also understand what you did now, cute
Exported 150 message(s)