« first day (2379 days earlier)      last day (1102 days later) » 

6:26 AM
````
let string = String::from("127.0.0.1:8080");
let string_slice = &string[10..];

dbg!(string);
dbg!(string_slice);
````
```
3 | let string_slice = &string[10..];
| ------ borrow of `string` occurs here
4 |
5 | dbg!(string);
| ^^^^^^^^^^^^^ move out of `string` occurs here
6 | dbg!(string_slice);
| ------------ borrow later used here
|
```
sorry about the formatting...
why is it that this error is being thrown? I was under the impression that string_slice = &string[10..] will be executed and it doesn't matter when I call dbg!(string_slice). But if I move it to before dbg!(string) everything works...
let string = String::from("127.0.0.1:8080");
let string_slice = &string[10..];


dbg!(string_slice);
dbg!(string);

why does this work?
 
6:57 AM
Specifically:
> Invoking the macro on an expression moves and takes ownership of it before returning the evaluated expression unchanged. If the type of the expression does not implement Copy and you don't want to give up ownership, you can instead borrow with dbg!(&expr) for some expression expr.
Does that help?
 
not exactly ... i am not using string after dbg!(string) right? So why does rust worry about it? Is dbg!(string_slice) using string in some way?
if i remove the dbg!(string_slice) after dbg!(string) everything works... and I was under the impression dbg!(string_slice) doesn't use string in any way, and there is no need to use dbg!(&string) there...
 
string_slice is a pointer over a part of string. It can't exist if you drop or move string
If you want to drop or move string and keep string_slice, you need to copy the relevant part, ie make a new String from the part pointed by string_slice
 
7:15 AM
oh, okay.
makes sense.
thanks @DenysSéguret @Jason
 
Happy to help! @illiteratewriter! :-)
 
 
2 hours later…
9:26 AM
Do you agree with me here ?
This question being very specific to problems related to the current state of a particular library, it would probably be more relevant on that project's issue tracker. — Denys Séguret 13 secs ago
 
I'll go with no MRE, because it's fairly accurate.
 
Saying there's no MRE means, to me, that the question could be fixed if OP added a MRE. Does that look possible here ?
 
 
1 hour later…
10:40 AM
OP has a question about a function which doesn't do anything. Code has at least 7 unwrap. No mention whether there are errors.
 
 
1 hour later…
12:09 PM
@DenysSéguret I wonder, is the tag even applicable here? It seems to be a Docker related issue?
 
Unsure, but it looks vaguely legit as it's about running rustup
This "serverless" lib doesn't look pretty or alive
 
12:44 PM
hello everyone
 
Good afternoon! :-)
 
@DenysSéguret to be clear my exact problem was that I was not sure how to transform it with the right type, so I ended up unwrapping it without any error handling. I know how ? works :)
 
@AntoninGAVREL Sorry but I'm lost here. What are you answering about ?
 
about snafu
1 or two days ago
sorry for missing the class :p
 
1:05 PM
@DenysSéguret you have a lot of experience with JavaScript, right? I was playing around with extending Event to trigger events, but I'm not sure what to think of what I currently have. Maybe you have given this some thought?
class ThemeEvent extends Event {
  constructor(theme) {
    super("themechange");
    this.theme = theme;
  }
}

window.dispatchEvent(new ThemeEvent("dark"));

window.addEventListener("themechange", this.doSomething);
 
You don't have to extend event, a CustomEvent facility is native
 
There's CustomEvent which inherits from Event as well, but puts custom properties in the detail property. I'm not sure, I see people arguing to use the former and latter.
Hum, yeah, it is somewhat confusing to me.
 
The ones arguing for extending may be old people from before the Custom Event normalization
As would say stargateur, don't listen to old people :)
 
With TypeScript it is somewhat nice to import e.g. ThemeChangeEvent and then at least have the consistency of having some types, but perhaps I should look into getting that to work with CustomEvent!
@DenysSéguret Haha
 
@Jason Leveraging TS type system does look like a valid reason to use a class. Didn't look into this myself
 
1:14 PM
I'll try it out! If I run into any issues I'll let you know.
 
2:03 PM
what was the issue with the red shirt?
 
2:44 PM
alright
thank you for sharing that was interesting
 
I shall call you Compte Denys from now on
;)
 
I would refuse the title if my father hadn't done enough himself
 
just kidding
I guess your father really enjoyed "les visiteurs"
 
> We have updated our SIMD feature explainer and added new instructions for feature detection, cross-compilation of code targeted for SSE/AVX/NEON to Wasm, and usage from Rust. v8.dev/features/simd
 
2:47 PM
Still behind a flag ?
 
No, right? Maybe I misread?
> WebAssembly SIMD support will be available by default from Chrome 91, while on older versions it's gated behind a flag.
I quickly skimmed it.
 
oh cool
 
 
4 hours later…
6:39 PM
-1
Q: Embedding hidden data in PDF files (JavaScript, Python or Rust)

Jefferson SofarelliI need to add some custom metadata to a PDF file that should be hidden from end users. Then I need to extract this metadata (to process it in another app) and be able to restore the original file (I mean: if I hash the file before adding the custom metadata and after extracting the metadata from ...

 
7:17 PM
@Stargateur Flagged the OP's comment.
 
@E_net4thecopycat "magic" is maybe not self explaining :p I answer trying to explain
 
7:54 PM
Is OP having no idea of the most basic rust syntax here ?
-1
Q: Call function in if statement

Rocknrolla ManHow do I call function in an if statement? In decl_modul!, I have function like this: pub fn unlock(origin) -> dispatch::DispatchResult { let user = ensure_signed(origin)?; ensure!(user == Self::authority(), Error::<T>::Forbidden); <Ends<T>>::put(T::BlockNumber::zero()); Paused::p...

Or what am I missing ?
 
Hum, odd. I have no idea what they're trying to do. I voted to close it as it stands.
 
After reading some of these linked questions, I genuinely feel sadness. Where are these people coming from? Why haven't they read the book? Why is it too much to ask to do some investigation themselves? Why did they choose Rust to begin with?
 
Exactly what I was thinking @PeterVaro it makes me sad.
 
Rust is victim of its popularity. I pray it survives the flood in spirit.
 
I'm more sad than my order pizza have been cancelled
 
8:06 PM
And it's such a shame as well, the book is so well written. I'm convinced anyone can learn a lot about general computing just by reading it.
 
I think the steep learning curve of the borrow-checker definitely helps on this one, as in, keeping the lesser people out. OTOH though that also means more and more people will complain how hard or bad the language is, when they were unable to do anything meaningful in it.
@FélixGagnon-Grenier I can honestly say, it is one of the best programming-language introduction books I've read. It is really, really well written, easy to follow, in-depth enough but does not explain overwhelming details, etc.
 
100% agree
 
However my judgement might not be insanely accurate, as I already spoke a dozen languages when I picked up Rust, low-level ones and very-high-level ones included.. So I have no idea how it would feel like to read it as a total beginner, or someone who chooses Rust as their, say, second language, coming from Lua.
 
Well, I chose Rust as my 3rd/4th language, coming from PHP, JavaScript and Python, and I was completely flaberghasted at the amount of dots it connected in my mind about lots of things.
As for total beginner, not sure either. I tried teaching it to a friend who have exactly no other experience with programming and it was rather unconclusive.
 
even if ocaml is not great but the book was good
 
8:14 PM
The OCaml book, you mean?
 
lol I really thought it was the meme o'reilly generator
 
Why did SO chat not inline that image? :thinking:
 
Haha, yeah @FélixGagnon-Grenier, one of the few covers with an appropriate image
 
@PeterVaro why would it? afaik it only inlines when there's any other character than the image
@Jason :D
 
I'm not following you..
 
like if one puts a dot . before the image path
 
@FélixGagnon-Grenier look real
 
now edit your comment and put a character just in front of the url and a space
pls, Stargateur, edit your image comment and add a dot before the url, to demonstrate the inlining?
 
I can't say I'm completely surprised but still..
 
8:18 PM
I don't follow why you ask me that
 
@Stargateur it does look real indeed!
because I was trying to show the inlilning to Peter
 
you mean... just a link ?
 
because I thought I had understood he had some confusion about what I was trying to say about it
 
I thought it was a meme also lol
 
@Stargateur is that dark mode for chat a userstyle or did I miss a setting?
 
8:19 PM
ocaml is NOT a meme
 
Nice chameau
 
@Jason dark reader extension
 
@Stargateur that's exactly what a troll would say
also nice keyboard
 
... it was a dromadaire
 
 
1 hour later…

« first day (2379 days earlier)      last day (1102 days later) »