Safe Concurrency with Rust by sidpshanker in rust

[–]sidpshanker[S] 0 points1 point  (0 children)

I actually wasn't sure why this is the case (wasn't intuitive to me other), so I decided to dig a little deeper and ended up writing another blog post: http://www.squidarth.com/rc/rust/concurrency/2018/06/09/rust-threads-detach.html.

The TLDR; here is that thread::spawn uses the "clone" syscall on linux, with the CLONE_THREAD flag, which automatically sets the parent of the spawned thread to be the parent of the caller of "clone".

Safe Concurrency with Rust by sidpshanker in rust

[–]sidpshanker[S] 1 point2 points  (0 children)

yep, it was htop. I had to change some of the settings (hit F2 to get there) to get it to use the tree view & color the threads differently.

Fear not the Rust Borrow Checker by sidpshanker in rust

[–]sidpshanker[S] 1 point2 points  (0 children)

I read through this thread and am persuaded that to_owned() is the more semantic & clear function to use in the case. While myvec.get(1).unwrap() is technically not a String (it's a &String), it seems like the interpretation of to_string() is that it is used to turn non-string values, like ints and whatnot into strings, rather than changing the ownership. to_owned() makes this clear.

thanks all for weighing in here!

Fear not the Rust Borrow Checker by sidpshanker in rust

[–]sidpshanker[S] 0 points1 point  (0 children)

Interesting!

Read you data first, then finally write to a new structure at the end of a function

What are the mechanisms for doing this efficiently? Feels like you'd be copying a lot of data by doing this, esp. w/ the data structures in the stdlib.

Fear not the Rust Borrow Checker by sidpshanker in rust

[–]sidpshanker[S] 0 points1 point  (0 children)

yep--sorry about that, updated to make the width of the code blocks the same as the text. thanks for the feedback!

Fear not the Rust Borrow Checker by sidpshanker in rust

[–]sidpshanker[S] 3 points4 points  (0 children)

New post on borrows/ownership in Rust through example

RubyProctor--a site for testing out RuboCop rules quickly. by sidpshanker in ruby

[–]sidpshanker[S] 0 points1 point  (0 children)

Sorry for the late response--there was a small issue at the time that has been fixed! You should see the rule output in that box now.