« first day (1802 days earlier)      last day (1669 days later) » 

7:46 AM
> This will create a &str from the String and pass it in. This conversion is very inexpensive
I always assumed there was absolutely no runtime cost. Is there one ?
 
8:08 AM
There is a pointer indirection, I guess
 
Oh yes I'm stupid, the indirection can't be solved at compile time ^^
 
and a new struct creation I believe, slices are not just references, but fat pointers, each of them stores their length as well
although I hardly believe that would ever be a bottleneck, but being pedantic, in theory, an &String is cheaper
(but from a public API's perspective, less flexible)
 
8:25 AM
@PeterVaro That's true as well
 
Can we close the last question ? Politely ask the owner to delete it ? Is there a good QA for closing as duplicate ?
 
9:09 AM
The only relevant questions I found are 1 and 2
 
9:34 AM
@DenysSéguret creation of a fat pointer ?
 
Obese pointer.
Hmm. Does converting trait objects into monomorphized types means we're giving pointers a diet?
 
9:48 AM
not sure if serious
 
The fun part is that monomorphization may also increase code size, even though the pointers get thinner or non-existent.
 
that's exactly what I meant when I said not sure if serious
you're duplicating the content of the function N times to save what, 32 bytes total per call?
better have short functions
 
@SébastienRenauld What we increase in size, we often gain in performance. Static dispatching brings more opportunities for AOT optimizations.
 
10:04 AM
I completely agree, but that's not always true and it depends on a whole host of factors, including what's inside the function
it's one of those things you need to profile to evaluate in most cases
also, bear in mind that not every environment has this tradeoff balance. some environments would take a penalty in performance if it means smaller compiled size because that's their real constraint
 
@SébastienRenauld that's exactly what I think should be emphasised here!
 
Let's not underestimate the compiler, though. Making functions generic with parameter types rather than trait objects is a good default until it starts adding up in complexity or bloat.
 
Well, if anything, let's not underestimate the power of profiling :)
 
And the power of ZCA's. If you can't take my word for it, take Shep's word. :>
 
I'm not arguing with you here, we are on the same page, all I'm saying is, instead of blindly believe/assume what the compiler would do for you -- just make sure it does.
Start implementing your stuff in a way that would be the most idiomatic way
and when you realise the compiler is not capable of doing what you thought it would be
then, and only then, introduce your manual optimisation
I think we are on the same page on this, aren't we?
 
10:19 AM
Aye.
 
you know the saying
test, observe, repeat
 
Kinda like science.
 
Most developers forget that
I've had to deal with somebody's code not long ago who was trying to play code golf in c with bitmasks
let's just say the golfing part would've been better without the underflow
 
10:55 AM
@SébastienRenauld the TOR principle.. I wish it had a H in there, you know, THOR
 
what'd it stand for
 
@SébastienRenauld I couldn't find any meaningful word for it, especially not at that position..
 
horsewhip sounds good
especially true when you're testing somebody else's implementation
 
LOL
test, HALP!, observe, repeat
 
11:10 AM
nice question on convention there
the ?Sized one
Also, potential vote close for this: stackoverflow.com/questions/58021920/…
 
 
4 hours later…
Snafu alert
> I could cryo-freeze myself until RFC 2504 is (fully) implemented but surely there's some way to do this.
Choosing between cryo-freezing or fixing the problem in the code, tough.
 
3:21 PM
some people try, they got problems, this is your choice
 
4:02 PM
Are you positive there's still no unsafe way to read from an enum without pattern matching ?
 
@DenysSéguret If that is an important use case, I'd look into unions.
 
@E_net4theMeta-RemoveR no, just curious for the question. I never had the need myself to bypass the test
 
@DenysSéguret I left a comment. I've seen some crates relying on this pattern of including getter methods returning an Option.
 
There should probably be a simpler standard syntax to get an option without the match
just like a standard method to check a variant and return a bool would avoid awkward functions just containing a match
 
@DenysSéguret what do you mean ?
0
Q: How to access each element from a tuple variant of enum in Rust

Nouman MustafaI have created an enum in which there is a variant of tuple named v4, in main function I need to access all the elements of that tuple one by one. I have tried to use unwrap function but it gives error that "no method named unwrap found for type Ipaddr in the current scope". #[derive(Debug)] en...

^ is it about this one ?
 
4:13 PM
@Stargateur yes, I wondered for a while if there was a no check method for when you know the variant
 
@DenysSéguret Perhaps a macro could cut on the boilerplate in a generalized fashion.
 
@E_net4theMeta-RemoveR probably but I would not import a macro just for that, it would have to be standard and clean
 
@DenysSéguret well, yes, this is not you must match and use unreachable
 
"meta remover" ?
 
@DenysSéguret Extensions to standard mechanisms of the language are not unheard of, though. itertools for extra methods in Iterator, clippy for extra lints, etc.
And if they become mature enough and an RFC is established, they can become part of the language. Having an implementation at hand helps.
 
4:15 PM
But this question is not really about that
 
@E_net4theMeta-RemoveR yes, and lazy_static is almost in this category
 
he just mess up with some basic programming
let me handle it
 
We'd need something like a typed variant for those cases
 
 
2 hours later…
6:10 PM
0
Q: Pointers as function arguments when implementing a structure

Eziz DurdyyevWhy there is a & symbol before self in the full_name() function but there isn't any in the to_tuple() function? When I look at them, the usage of self is similar in both function, but why use &. Also when I change anything it would throw an error. Can someone explain it? fn full_name(&self) -> S...

When I change the code it's doesn't compile ??
wtf is this question
 
 
4 hours later…
9:42 PM
Uh oh, without boats implemented exceptions on top of Rust.
https://github.com/withoutboats/fehler
 
NEVER
 
10:05 PM
Gosh, please no..
 
10:23 PM
Maybe I'm being dumb, but...
did they just reimplement ? in a different way?
 
I don't think there is many way to implement exception in a language like Rust
probably long_jump
 

« first day (1802 days earlier)      last day (1669 days later) »