« first day (1925 days earlier)      last day (1546 days later) » 

7:34 AM
You can't tell in Cargo.toml that you need a recent version of Rust, right ?
 
8:04 AM
I always get messages "broot doesn't compile" and it's just that people have a rustc prior to some (stable) version I need
 
8:35 AM
@DenysSéguret nope, some proposition have been made
@DenysSéguret yeah...
Try to put it in first of the README file
0
Q: Rust: Generic Vec

SleepyX667I have the following code-snippets (don't question the sense of them ;) ) 1. get the n-th element of a Vec recursively fn helper<T: Clone>(n: usize, current_n: usize, current_xs: &Vec<T>, accumulator: Option<T>) -> Option<T> { if current_n > n { accumulator } else { let ...

this code hurt me
 
8:58 AM
4 issues created since yesterday by people who have an old rustc...
 
@DenysSéguret ah people who don't look closed issue
duplicate
everywhere
 
yeah
and sometimes, it's at the bottom of a previous issue...
But seriously, this is a serious shortcoming of cargo. Users should not have to guess themselves that the compilation bug is related to their rustc being two months old
 
@DenysSéguret well here I disagree 2 months is not old :p
the problem is everyone have to face this kind of problem at least one to understand and get the reflex to update rustc
 
But many developers on linux just have the reflex to compile from source and don't really know rust. It would be good to look welcoming to here with a toolchain explaining them the problem (which is already the case for most of rust)
 
@DenysSéguret that clearly needed, we need a better way
 
9:07 AM
@DenysSéguret i was about to tell the idea, but i found a create which already implements it, crates.io/crates/version_check
 
@ÖmerErden nice this should work most of the time
 
or running a simple buildscript which calls cargo rustc -- --version
 
@ÖmerErden Interesting. Too bad to do the work of cargo but this could be a workaround. I already have a build.rs
 
that will not work for dependency
there are compiled before build.rs
 
but cargo compiles also libraries before your executable ?
Build script is not running on that time ?
Lib's build script *
 
9:11 AM
yes but you can't control the lib build script
they could have use "version_check" too but probably not
 
but it's a build-dependency of the library
 
Also, I think this should produce a big warning not an error
 
It will not compile the lib at the end right ? Since that version of rustc is not able to.
if it compiles but that makes a behavioral differences then imo it shouldn't compile ,
 
9:35 AM
Meh, I usually just leave a badge at the readme file with the minimum compiler version guaranteed to work.
 
9:47 AM
@Shepmaster congratulations I guess to your post on stackoverflow? ^^ Not sure if it's something one should congratulate to
 
9:57 AM
stackoverflow.com/questions/tagged/c ,am i missing something why there is a QT icon near C tag ?
 
10:21 AM
play.rust-lang.org/… => call this idiomatic rust
here is a more idiomatic implementation — Stargateur 38 secs ago
I was forced :p
@ÖmerErden wtf
They really did that ?
53
Q: The C tag is being displayed with a Qt icon

Keith ThompsonThe c tag is being displayed with what appears to be a Qt icon (and the qt tag is not). Tag wiki (Screenshot below)

CALM, look it's a bug :p
 
11:17 AM
Ahah, ok now i am calm ^^
@Stargateur wow i didn't know this doc.rust-lang.org/1.8.0/book/slice-patterns.html
 
@ÖmerErden what I used still require nightly, github.com/rust-lang/rust/issues/62254
strange it should not...
ah nevermind
there is just not stable 1.42 yet ^^
 
Since i am so stable i had no idea about nightly features :P
 
this feature is really good make write code with slice so much better
 
Indeed i liked it very much
 
11:40 AM
@Stargateur Do you often use slice matching ? For what ?
 
@DenysSéguret I doesn't write much rust code outside SO... but until now I used 3 times I think
and if you want an example I just create one :p
 
Hum... in fact I could use it for some hacky string (as bytes) matching
 
@DenysSéguret ooo I don't see what I read :p
 
@Stargateur I've seen a few hacky examples, not any one really convincing
 
well my example is totally valid here
actually you could even do better:
fn helper<T>(x: &[T], acc: usize) -> Option<&T> {
    if let [head, next @ ..] = x {
        if acc == 0 {
            Some(head)
        } else {
            helper(next, acc - 1)
        }
    } else {
        None
    }
}
well, better is a matter of taste
 
11:45 AM
Well... half the (few) examples I've seen where needlessly recursive (and suboptimal)
 
ofc this example premise a bad use of slice in the first place
you can summarise at everywhere there is something like &[1..], split_at split_at_mut, you could probably use this feature
 
11:58 AM
hmm.. interesting.. I thought all closures have different types regardless of their origin: even if they are created in a loop
 
that obvious no ?
 
it is not
the two will have different types
 
yes every closure have a single type but in your example f is f
why f should change of type ?
also, how the compiler could know how many closure to generate?
 
that last one is a good argument, yes -- but it is only needed in scenarios where global uniqueness should be established, e.g. Any
(btw the same thing happens if you have for example a function factory)
 
12:21 PM
on an unrelated note, would you choose a LinkedList if insertion and removal of elements at random places happening very, very often, you don't care about the order, but you want to have duplicates to be stored and you will only want to iterate over the elements never want to access them directly at a specific location?
(the reason I'm asking, because I would by default choose a Vec but this specific scenario is the exact one where a LinkedList makes a lot of sense actually..)
 
I would use either a mix or a vector of vector
 
a mix?
 
linkedlist of vector
 
how does that help?
 
@PeterVaro vectors also have amortized O(1) insertion, if you can always append to the end
obviously the true answer is benchmark it
 
12:25 PM
@trentcl but if I randomly remove elements from the middle that won't be O(1)
 
@PeterVaro right, but it'll be O(n) for either a LL or a vector
LLs only have O(1) insertion/removal when you have a cursor pointing to the element already
... I guess it depends on what you mean by "at random places"
 
@PeterVaro If you don't care about the order use swap_remove
 
damn, LL does not have a retain..
 
using a good size for you vector you could have all pro of vector without inconvenient to move 1000000000000 element, imagine you have 10 vector, this mean when you change 1 elem of vector 4 you just have to change vector 4. With some code to "equilibrate" the size of your inner vector when it become too big, this is a very good way to fill your requirement "you will only want to iterate over the elements never want to access them directly at a specific location"
ofc all this pain come from "if insertion and removal of elements at random places happening very, very often"
 
right, so the idea is this: I store Rcs as elements -- and from time to time I have to iterate over the elements and if an element has exactly one owner, I remove it from the container
 
12:28 PM
@mcarton swap remove if you don't care of order but this only work for removing
 
with a HashMap this was easy, because with the HashMap::retain I could do this in one go, therefore insertion and deletion is O(1) in my case
 
@PeterVaro I not sure I understand you, I never talk about Rcs
 
but I want to have duplicated elements in there
 
@PeterVaro hashmap of vector ?
quite heavy
only useful if there is a lot of duplicate
 
@Stargateur And use Vec::push which is amortized O(1) for insertion?
 
12:30 PM
@PeterVaro sounds like a Vec to me
retain is probably going to be faster than anything you can do with a LL
 
@mcarton "if insertion and removal of elements at random places"
 
@trentcl but then you would either end up with holes, or you would move O(n) elements on every deletion
 
anyway if your requirement are this I advice you vector of vector and some code to manage it
 
@PeterVaro mmm... I suspect the cost of copying is dwarfed by the cost of following all those pointers
 
@Stargateur I understood that as "(insertion) and (removal of elements at random places)" since he doesn't care about the order
 
12:32 PM
Divide and conquer
@mcarton he never said he didn't care about order that you who said that :p
 
@trentcl not if I could remove as I iterate
 
> you don't care about the order
nevermind
 
@PeterVaro with a LL you still have to follow N pointers so you have O(n) cache misses
vectors are nicely laid out in contiguous blocks
 
when your vector become too big you will have cache misses anyway
 
@trentcl I'm aware of that, I still don't understand your reasoning -- which may not be even important as I don't think mutable iteration is a thing with LLs
 
12:35 PM
@Stargateur yes, but probably much fewer
 
right, cache misses -- I think I'm convinced
 
if your data is not too big, yeah vector is the better on your case
but that become you don't care of order :p
 
@Stargateur I believe (without testing it) a vector is better than a LL no matter what the data size
 
@trentcl I didn't advice a LL
I advice a LL of vector
 
now, if your data becomes super large, a tree-like/ vector-of-vectors like you're talking about, yes, I agree with that
 
12:37 PM
or a vector of vector
 
ok, just to be clear
 
how would that work?
also there's another possibility, to keep holes in the vector and keep a "writer pointer" to make the insertion lesser than O(n)
 
@PeterVaro like a hash table but without the hash
 
yeah, I was thinking of a ring-buffer like thing, but yes both similarities are okay
 
the point of the vector of vectors is that you don't move all the elements in the big vector every time you remove one
however, if you need to remove many at a time, it may not be worth it as you end up moving most of them anyway...
 
12:45 PM
right, yes, this is the point where actual profiling makes more sense
I think for simplicity at the moment -- and because this is just an interview test -- I would go with my patchy-vec solution
 
use vector => test => bench => if too slow => try something
 
On the other hand, you could continue using a HashMap but wrap the Rcs in a wrapper with a custom Eq, so it doesn't deduplicate them.
 
unfortunately the exact requirement is not described in the task
 
*custom PartialEq, that is
 
@trentcl I was thinking about that, and basically give each newtype wrapper an incrementing ID
 
12:48 PM
=> don't forget vecdeque exist
 
@Stargateur it is not a good solution in my situation unfortunately
 
@trentcl I don't like this kind of trick :p
 
@PeterVaro I don't even think that would be necessary, if you just implement PartialEq so that it always returns false
 
@trentcl now I feel very stupid.. yes, of course
:face_palm:
but that would mean if their hashing is coming from TypeId
then there could be a lot of collision
in the bucket where duplicates live
 
@Stargateur shrug it's only a little tricky
@PeterVaro yes, it could be a problem.
 
1:10 PM
@hellow you can't just make naughty comments about transmute and then replace them by a much more reasonable way! :D
 
I really don't see the point of answer the question about float
 
@Stargateur Me neither to be fair, but I wanted to say that those different ways of declaring a float are not actually 3 different ways of declaring a float
 
there is only one way to declaring a float
and it's let x: f64 or f32
period
 
I'd argue you even don't need the type most of the time
 
let (x,): (f64,) </pedant>
 
1:26 PM
@trentcl :D
I don't know if I should update the answer to add more ways like this
 
@mcarton sorry ¯_(ツ)_/¯
I remembered, that there's a reasonable way ^^
 
1:45 PM
user image
2
 
2:01 PM
@Stargateur why not using *mut T everywhere? No more borrow problems
 
@hellow yeah we could make this image much better
 
The question about all the ways to declare a float is actually quite popular, should we also make a question about all the ways to ignore the borrow checker?
 
@mcarton the answer is you can't
unsafe doesn't mean "turn off the borrow checker"
 
Well, using *mut T everywhere certainly makes it easier to ignore it, even if it's still there
 
2:33 PM
@mcarton I feel like there is a question for that, but I didn't find it in 30 seconds
 
2:50 PM
What I really meant was "should we also make a question about all the stupid ways to ignore the borrow checker?", but maybe we actually should make such a Q&A with serious As
 
The question I remember (or made up) was more like "how can I disable the borrow checker"
globally
I guess the literal answer to that now is use mrustc
 
TIL about mrustc
The readme really really lacks a "Why?" section
 
@DenysSéguret it's self evident ;-)
 
"All the complexity of the borrow checker without the safety" ?
 
I think the real reason is so that there is some alternative compiler
 
2:55 PM
"Your boss chose rust for the safety but the lack of bugs is threatening your future maintenance job ?"
4
 
Also potentially used as a bootstrapping step to new platforms
e.g. if the platform has a C compiler but not LLVM
 
Can't you keep the borrow checker part ? Is it tied to LLVM ?
 
I think it's more like "the borrow checker part is really hard"
 
@DenysSéguret They could but haven't implemented it yet?
 
not "we will never do it"
 
2:57 PM
You can always first compile with good old rustc and then only if that one is OK with your code, use mrustc
 
@mcarton This does make sense
 
I think that's the intended usage, yeah
 
3:46 PM
we are in 2020 and people STILL DON'T USE UTC, twitter.com/11bitstudios/status/1219635120690343942/photo/1
 
@Stargateur I honestly don't understand why people didn't start using Swatch Internet Time in the nineties! I was using it with my friends and we all loved it :)
it was global, it was 10-based, it was fun -- it was cool.
 
that could be a good thing to do not the first time I hear about having a 10-based time
because currently time is a total mess
 
a massive mess, yes
 
but when I saw people can't use UTC I have my doubt
 
in humanity?
 
3:51 PM
look american they are officially using metric system since... 70 years ?
 
haha.. I lost hope about us a long time ago :P
 
people still use imperial bullshit
worse they DEFEND it
one problem with your swtch time is 1 s 0.011574 .beats
 
you won't use seconds anymore though..
you just say @952 and that's it
 
but the second is very used, if I follow people would use 11.5 mbeats
 
My only defense of imperial: 1. Fahrenheit has nice range and granularity for what humans tend to live in. 2: one foot being 12 inches is nice to divide into smaller pieces easily (1/2, 1/3, 1/4, 1/6)
 
3:55 PM
well.. that could be ok
 
That being said, I'd be happy switching
My car happens to be in km/h and liters/100km
 
@Shepmaster 1. celsus is better on that 2. yeah 12 base is practical
but you can use base 12 and still use standard unit
just need to convert thing sometime... probably not a good idea to do
 
I'm not sure how you say better for my case. My point is that 0F -> 100F is more-or-less temperatures that humans thrive in. That's a nice range, compared to (roughly) -10C -> 30C
 
/me does not thrive at 0F
It was 0C today and I've been complaining all day
 
I'm with you there, but it was the general human ;-)
I'd be down with 0 degrees being "water freezes" and 100 degrees being "body temperature"
 
4:03 PM
At long as it's not 0 → body freezes and 100 → current water temperature somewhere random
 
@Shepmaster "body temperature" is a stupid limit
I don't follow you we have real number in france
you can say it's 15.5 C
 
My point is that a temperature scale optimized for human comfort is useful. A different scale for science is also useful.
 
I don't agree at all
 
I think you do, which is why you say 15.5C, not 288.65.
 
It's most useful in every day to know that water freeze at 0 and boil at 100
well celsus is a good balanced between science kelvin and use
 
4:51 PM
> Rust doesn't have gcc-like dynamic stack arrays.
I hope so, this feature is the WORSE feature gcc ever made
I don't know one people who advice it
 
my recollection on this one is quite hazy, dynamically sized static arrays were introduced to C99 (maybe C11) because someone implemented them as an extension to GCC or was it the other way around?
 
I can never tell, is that the same as VLAs?
 
(that's what I thought @Shepmaster)
 
@PeterVaro and REMOVED in C11 ;)
 
4:56 PM
@Shepmaster omg no
 
@Stargateur nope, it just became optional
as in, now the __STDC_NO_VLA__ is mandatory to be defined
 
I think it was removed in C18 -- but I'm not even sure about that
 
@PeterVaro yeah... but I like say it have been removed :p
@PeterVaro no I don't think so
but something optional is almost the same that removed
in this context
 
yeah, I gave up on C a few years ago, I didn't go through the C18
 
4:58 PM
there didn't make much change
 
@Stargateur even if before it was mandatory?
I don't think so..
 
well, MSVC never added it xd
but MSVC is not a C compiler
 
@Stargateur In the world of C and C++, making something optional has no effect. People are still going to use it just as much.
 
@Stargateur my thoughts exactly
 
anyway, a code that use VLA is bad
 
5:01 PM
@Stargateur but you didn't answer my original question: was VLA introduced first in GCC or in the standards?
(I'm just curious)
 
@PeterVaro first was gcc
like many thing in C
 
yeah, just as I thought..
 
@Stargateur The linux kernel is a weird beast anyway, it not a typical C project
For starters: it's not actually C, it's C with a many extensions
 
@mcarton typical C project should be buried in the ground very deeply
 
5:27 PM
I can't stand my current job. I'm porting some cryptic VB models to java and it's only the part of the hell I can describe. I need a remote rust job ASAP.
 
@DenysSéguret you want to port some cryptic VB models to Rust?
 
@Shepmaster depends on the environment of the whole (is unit test a valid concept ? and what about a safe behavior on limits ?) but I would be OK
 
@mcarton I'm tempted to delete the content of your float answer and replace it with like "16"
 
Deploying by drag & drop using remote desktop on VPN on the production server is for example something I'm tired of
 
@Shepmaster Why 16?
 
5:37 PM
@DenysSéguret powershell to the rescue!
@mcarton the exact number doesn't matter, I just want a snarky answer to "how many are there" ;-)
 
Oh :D
Then I'd guess it's more than 16
 
 
2 hours later…
7:13 PM
@DenysSéguret look this WONDERFULL database with API... wait it's... excel and tons of macro
 
 
1 hour later…
8:39 PM
@DenysSéguret ugh.
 
 
3 hours later…
11:17 PM
@DenysSéguret wow.. that sounds like a new low -- my honest condolences!
 

« first day (1925 days earlier)      last day (1546 days later) »