« first day (1555 days earlier)      last day (1920 days later) » 

1:24 AM
Alright, this seems like a duplicate
2
Q: Rust struct with member that points to the struct itself

Callum RogersI'm trying to make an assertions library for testing in Rust. Currently, I have statements like: expect(value).to().be().equal_to(4); It would be really nice to drop the parens on filler to and be functions to make it something like: expect(value).to.be.equal_to(4); I think this requires th...

But there are 3 answers already
 
1:46 AM
Ok, I think I sussed out what was really being asked
 
2:05 AM
2
A: Is it possible to map an Rc<T> to get an Rc<Subpart-of-T>?

JacksonCoderShort Answer No, it's not possible to create a Rc<T> from an Rc<Option<T>> that leaves the latter still existing. It is possible to create an Rc<&T> however, from a Rc<Option<T>>, while still leaving the latter variable existing. Long Answer If you're trying to create a new Rc<T> that owns the...

not bad for a new user
first ```
that is so good ^^
 
2:24 AM
@Shepmaster BTW, can you hammer the last one I linked
 
sounds good, thanks!
 
perfect
 
@Stargateur you didn't have to delete your answer
 
@Shepmaster you think ?
I don't care of the point
 
 
12 hours later…
2:29 PM
Hey, a question about one of my libraries
1
Q: sxd-document / sxd-xpath failing to parse XML

EishI'm can't seem to figure out why this isn't working. I have an external XML file that I'm trying to traverse via XPath. My code is: extern crate sxd_document; extern crate sxd_xpath; use std::fs; use sxd_document::parser; use sxd_xpath::{evaluate_xpath, Value}; fn main() { let contents = ...

 
2:53 PM
@Shepmaster Might feel gud
 
Except it means that something wasn't great enough for them to figure out
 
... IDK, I'm not sure that's on you. I would have suspected a namespace issue. It's a little unfortunate .expect() is the first thing everyone reaches for.
And I mean without the stack trace, I would have looked at namespacing. I think the stack trace makes it pretty clear.
 
 
2 hours later…
5:17 PM
@Stargateur Also, not bad for a 16 year old
 
5:56 PM
@Stargateur: It's possible with C++ shared_ptr to get a shared_ptr to a field, or element of an array, and share the same "counter". — Matthieu M. 7 hours ago
@MatthieuM. I don't see the rational, this seem very unsafe, basically how do you free the ptr if the last shared_ptr don't contain the good ptr ? This seem just to break the api of shared_ptr. Possible != should — Stargateur 5 mins ago
@CallumRogers: It would be safe... though I just realized it'd be leaking :) Counters need to know the original pointer and have a function to run its destructors. I've got no idea how to enforce the lifetime relationship properly, though. — Matthieu M. 2 hours ago
@MatthieuM. XD
 
6:17 PM
@Stargateur Yeah. In C++ it's easy: you use the aliasing constructor and if you put a pointer to something that'll die too early... well it's on you. Didn't you read the doc?
 
@MatthieuM. what the point to use shared ptr if you don't have the safety
just use pointer
 
In Rust, for it to be safe, you need to enforce that lifetime relationship and it doesn't sound that easy...
 
because it not safe
also it doesn't make sense
I don't see real usecase
 
@Stargateur It's safe if correctly constructed; which is useful... some times. I think I've used it maybe once or twice in 11 years...
 
That can't be safe
as I said how shared ptr free the pointer at the end
magic ?
if you free a random pointer you will probably crash
 
6:20 PM
The same way std::shared_ptr<void> does it: there's type erasure at work at the moment you first construct a shared_ptr :)
Type erasure is, I suppose, a kind of magic ^^
 
I don't know this
and std::shared_ptr<void> don't make anysense
just don't use black magic
Re: option, it's just an example, imagine it try to get a field in a struct that always exists instead. — Callum Rogers 9 hours ago
I mean what is this
you are tired to write your_variable.toto
and you want something magic to be able to write toto ???
my answer will be write in C in that case
 
It's more an issue when having to conform to interfaces: you have a Rc<Foo> which contains a member Bar from a 3rd-party library, and you need to pass it to a function expecting a Rc<Bar>. And it's crucial that Foo lives as long as Bar does, cause its destructor will do something.
There the aliasing constructor makes sense.
It's most niche because Rc is niche, really. As soon as you start having Rc, the aliasing constructor is pretty natural :)
 
@MatthieuM. just throw a lib function that expecting that
 
@Stargateur / @PeterHall you know you can leave a comment on their question encouraging them to keep it up. Positive reinforcement and all that ;-)
 
@Shepmaster my upvote is enough
 
 
2 hours later…
8:16 PM
Can you use write! in no_std?
It would be an improvement over stackoverflow.com/a/54224365/3650362
 
It's in core... so I'd be tempted to say yes.
 
8:51 PM
@trentcl @MatthieuM. y'all are messing with me now
0
Q: How to use `core::fmt` to format to a fixed size buffer on the stack?

Chris BeckI'm using Rust for an embedded environment where we don't have an OS and we are building are target as no_std. We have implemented a special pathway for the device to log error messages in case of panic -- I'm trying to implement a panic_handler lang item. Our initial version (working) looks li...

 
9:01 PM
> someone on reddit suggested using derive_builder
proceeds to not show that code at all, plus a whole bunch of other changes
 
That Q really bothered me. What does 'fails' mean? Parses nothing? Excepts in your final except call? Gets halfway through? Spits out a stack trace? Falls silently into a black hole?
 
 
1 hour later…
10:18 PM
..Wait, avoid monomorphization?
 
10:39 PM
@E_net4wisheshappyholidays yeah. Check my intermediate title.
Needs improvement but I don’t have a great idea.
 
-_-
There are certainly other questions about making a function accept trait objects as well as non-trait objects.
 
Trait with method that takes an iterator and can still be a trait object.
 
*beard scratch*
 
10:58 PM
@E_net4wisheshappyholidays you lie !
 
@Stargateur Sir, are you implying that I do not have a beard!?
 
@E_net4wisheshappyholidays that not a beard you have
it's a barbichette
 
@Stargateur Preposterous! I shall not give such a name to my beard!
 
Time for a related video. *walks away*
 
11:07 PM
@E_net4wisheshappyholidays this beard tonic is amazing
 

« first day (1555 days earlier)      last day (1920 days later) »