3 ms·
the author has some recommendations, to quote formatting): > Suggestions: > > Generally, String > If you deal mostly with string literals but want som
by dathinab 2y ago
the author has some recommendations, to quote formatting):
> Suggestions:
>
> Generally, String
> If you deal mostly with string literals but want some flexibility (like clap), generally you'll want Cow<'static, str>
> If a profiler says your strings are a problem:
> Try different crates and settings for that crate out with a profiler
> O(1) clones are important when doing a lot of clones.
> For one-off allocations, they are slower.
> For short-lived programs, look into string interning
i.e. author thinks you should profile with your own use case
EDIT: Not sure why HN removes indention between a leading > and the start of the text, makes quoting unnecessary hard
- samatman 2y agoHTML doesn't do indentation. I typed four spaces between every word in these sentences.
- dathinab 2y agobut HN doesn't provide me with a HTML input field but a text input field and HTML has stuff like <blockquote> absent from HN input format and properly converting user input is a bread and butter task of anything displaying user content so HTML collapsing whitespace is really meaningless for the argument IMHO
- masklinn 2y ago> Not sure why HN removes indention between a leading > and the start of the text, makes quoting unnecessary hard Because HN’s markup is the most dreary, half-assed, and useless one in the history of lightweight markups. HN will remove a bunch of characters it doesn’t like because they might be used for fun, parse two+ newlines as a paragraph break, 4-indent as a literal block, and mis-parse * as emphasis. That’s it. So you get all the drawbacks of HTML with almost none of the tools provided by even just the original markdown. No quoting, no line breaks, no lists, no inline code, …
- wizzwizz4 2y ago2-indent is a literal block. 4-indent also is, but only because it's a 2-indent. HN markup also supports \-escapes (so you can write \*hello\* to get *hello*), but they grow linearly, not exponentially, with repeated escapes (\\\* becomes \\*). It also truncates long URLs in display, and it handles a single pair of parentheses in them (so you can write https://example.com/print(%22Hello,%20world%21%22) https://example.com/print(%22Hello,%20world%21%22)). But I think that's all.