https://github.com/KerfuffleV2 — various random open source projects.

  • 2 Posts
  • 7 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle


  • Thanks for the reply. Unfortunately, I could just use Any for that since Vec is 'static as long as the items are (and I don’t think you could use anyvec if the tiems weren’t static).

    I asked in the Rust Discord channels and it seems like my approach is fine. Even the mutable version is okay and doesn’t need to be unsafe if it returns the reference with self’s lifetime.


  • The more I think about it, the more I’m convinced the immutable slice version is safe. I’m pretty sure the mutable version in the playground is also safe because you can’t turn it into a mutable reference without consuming it and it requires a mutable reference to build.

    The mutable version is pretty inconvenient to actually use if you want to store the AnySliceMut and pass it to other functions. The other function would have to reconstruct it and pass it back once it was done with the mutable reference. But what if:

    // ^ impl AnySliceMut
        pub unsafe fn as_slice_mut(&mut self) -> Option<&'a mut [T]> {
            if TypeId::of::() != self.tid {
                return None;
            }
            Some(unsafe { std::slice::from_raw_parts_mut(self.ptr as *mut T, self.len) })
        }
    

    Obviously it’s possible to abuse but if I just do something like pass it to a function that takes a mut ref and that function doesn’t do anything weird like save the reference is this okay? MIRI is apparently okay with it: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=149ad441a1c66b3f1fd7f2107acbeccf



  • Would a link to crates.io be enough here?

    I’d tend to say: probably not. It’s not that people don’t know that crates.io exists, right? So that’s not changing anything.

    or want to find a new crate for some topic I go to lib.rs

    And lib.rs will suppress the visibility of crates it thinks are “bad” and you’d never even know the crate existed to go look at the objective data on crates.io. Or let’s say a result comes up but it’s just an empty page with a link to crates.io: you won’t have enough information to know whether it’s worth going through the trouble of following a link to another site and a lot of people wouldn’t bother.

    So I don’t think that change really solves anything.



  • Do you have suggestions what the future of lib.rs should be?

    Not the same person, but my suggestions would be:

    1. Reverse the decision to go closed source. Making stuff less transparent isn’t really going to help, and the primary controversy is coming from philosophical differences not the code itself. You can’t practically (and really shouldn’t) hide your policies. So going closed source is just another thing for people to complain about.
    2. Allow opting out of the opinionated parts in a relatively easy way. You can’t force other adults to align with your philosophy here, and trying is just going to cause problems.
    3. Personally, I think a better approach to the opinionated part isn’t directly changing data or obscuring/deprioritizing results. What you could do instead is add a section that has some context about why you think certain categories/crates are harmful. This makes the information available but doesn’t force people to do any particular thing.

    I think by taking that approach you’ll avoid a lot of the backlash because you are allowing people a choice.

    I’m not a lawyer and this isn’t legal advice, but personally I’d be pretty careful about editorializing/moderating content in this kind of situation. Suppose someone publishes as crate that actively causes harm. Users download it and get their data stolen/wiped/whatever. Can they reasonably have an expectation that you should have protected them from that sort of thing? After all, you are editorializing the content and going so far as to moderate content that doesn’t cause direct immediate harm to an individual but even content that potentially is harmful to society.

    Possibly I should disclose that I avoid lib.rs currently because I don’t agree with the philosophy of editorializing crates and personally I hate opinionated stuff that doesn’t give me choice/control. I use open source software/resources specifically because I care about having a choice. We don’t disagree philosophically on points like the harm of crypto such as bitcoin, I just don’t like this approach to dealing with it. Also, painting all crypto stuff with the same brush can potentially delay less (or maybe even non-?) harmful alternatives that don’t involve wasting massive amounts of computation to no end.