Why Nostr? What is Njump?
2023-12-08 00:13:45

Shane Celis on Nostr: So in #rust characters in strings can't be accessed via index because they're proper ...

So in #rust characters in strings can't be accessed via index because they're proper utf8 blah blah blah. So I have some code where I check the last character `string.chars().last() == ‘\n’` and I've been fretting, thinking it's O(n) and that I should stick that newline at the beginning of the next string in my sequence because `string.chars().next() == ‘\n’` is O(1). But it turns out chars().last() is O(1) too. Fancy that.

https://doc.rust-lang.org/std/str/struct.Chars.html

Author Public Key
npub1lyl9nhvpfjgyf76xe6qm2v38sxxftz0y097cq86rn7zd4jtpndas2s3dml