Post ATAxooURkz8MTOjGeO by mo@mastodon.ml
(DIR) More posts by mo@mastodon.ml
(DIR) Post #ATAxonONq2gp4IsuYq by fasterthanlime@octodon.social
2023-03-01T15:08:55Z
0 likes, 0 repeats
It has been 0 (zero) days since orphan rules meant I have to talk to the maintainer of some crate so they extract types from their platform-specific crate
(DIR) Post #ATAxoo2nPn135dnBYG by fasterthanlime@octodon.social
2023-03-01T15:12:13Z
0 likes, 0 repeats
Ok how criminal is this: I have a Vec<T>, I need a Vec<Compat<T>>, Compat is a tuple-struct#[repr(transparent)]... I should be able to std::mem::transmute, right?Is this a use-case for safe transmute?
(DIR) Post #ATAxooURkz8MTOjGeO by mo@mastodon.ml
2023-03-01T15:31:00Z
0 likes, 0 repeats
@fasterthanlime rustc can't optimize it automatically?
(DIR) Post #ATAxwzsPJ2YC6Wq3t2 by fasterthanlime@octodon.social
2023-03-01T15:32:31Z
0 likes, 0 repeats
@mo for T => Compat yes.for Vec => Vec>.. how would that work? I need to .into_iter().collect() at the least
(DIR) Post #ATAy5bRxUcggx8ZTnc by mo@mastodon.ml
2023-03-01T15:34:05Z
0 likes, 0 repeats
@fasterthanlime ...and that collect could be optimized because1. Original Vec is moved and cannot be used after2. Result Vec is same len3. Vec elements has same bit representation
(DIR) Post #ATAyAB1BC40yQKE6UK by fasterthanlime@octodon.social
2023-03-01T15:34:47Z
0 likes, 0 repeats
@mo I don't think the compiler can see that far, but it would be an interesting bit of research.
(DIR) Post #ATBoczXY8t4Mq8QdJQ by cliff@octodon.social
2023-03-02T01:22:44Z
0 likes, 0 repeats
@moBut wouldn't collect change the capacity of the Vec (in the general case)?@fasterthanlime