Telegram Group & Telegram Channel
Forwarded from Pragmatic Programmer (Nikita Bishōnen)
Немного размышлений на тему Rust и его развития без стагнации.

Для поддержания этого "девиза" в Rust появились "издания", сейчас на носу издание 2024.
Вот среднего размера изменение, которое это издание привнесёт.
С ним, код работающий в издании 2021:


fn indices<'s, T>(
slice: &'s [T],
) -> impl Iterator<Item = usize> {
0 .. slice.len()
}
...
fn main() {
let mut data = vec![1, 2, 3];
let i = indices(&data);
data.push(4); // <-- Error!
i.next(); // <-- assumed to access `&data`
}


перестаёт работать и выдаёт ошибку, потому-что новое издание задействует lifetime в возвращаемом impl Trait.

Для исправления предлагается ввести некий use:


) -> impl Iterator<Item = usize> + use<> {
// -----
// Return type does not use `'s` or `T`


и на мой взгляд, это конечно выглядит как костыль. Думаю сейчас я понимаю тех, кто в мою молодость программиста сидел и говорил что Java 8 это всё сахар и не нужно программистам. Думаю что дальше тянуть обратную совместимость у Rust будет получаться всё сложнее и сложнее, пора работать над Rust 2.0.



group-telegram.com/type_driven_thoughts/201
Create:
Last Update:

Немного размышлений на тему Rust и его развития без стагнации.

Для поддержания этого "девиза" в Rust появились "издания", сейчас на носу издание 2024.
Вот среднего размера изменение, которое это издание привнесёт.
С ним, код работающий в издании 2021:


fn indices<'s, T>(
slice: &'s [T],
) -> impl Iterator<Item = usize> {
0 .. slice.len()
}
...
fn main() {
let mut data = vec![1, 2, 3];
let i = indices(&data);
data.push(4); // <-- Error!
i.next(); // <-- assumed to access `&data`
}


перестаёт работать и выдаёт ошибку, потому-что новое издание задействует lifetime в возвращаемом impl Trait.

Для исправления предлагается ввести некий use:


) -> impl Iterator<Item = usize> + use<> {
// -----
// Return type does not use `'s` or `T`


и на мой взгляд, это конечно выглядит как костыль. Думаю сейчас я понимаю тех, кто в мою молодость программиста сидел и говорил что Java 8 это всё сахар и не нужно программистам. Думаю что дальше тянуть обратную совместимость у Rust будет получаться всё сложнее и сложнее, пора работать над Rust 2.0.

BY Type Driven Thoughts 🦀


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/type_driven_thoughts/201

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

"Someone posing as a Ukrainian citizen just joins the chat and starts spreading misinformation, or gathers data, like the location of shelters," Tsekhanovska said, noting how false messages have urged Ukrainians to turn off their phones at a specific time of night, citing cybersafety. "This time we received the coordinates of enemy vehicles marked 'V' in Kyiv region," it added. Again, in contrast to Facebook, Google and Twitter, Telegram's founder Pavel Durov runs his company in relative secrecy from Dubai. Right now the digital security needs of Russians and Ukrainians are very different, and they lead to very different caveats about how to mitigate the risks associated with using Telegram. For Ukrainians in Ukraine, whose physical safety is at risk because they are in a war zone, digital security is probably not their highest priority. They may value access to news and communication with their loved ones over making sure that all of their communications are encrypted in such a manner that they are indecipherable to Telegram, its employees, or governments with court orders. "We're seeing really dramatic moves, and it's all really tied to Ukraine right now, and in a secondary way, in terms of interest rates," Octavio Marenzi, CEO of Opimas, told Yahoo Finance Live on Thursday. "This war in Ukraine is going to give the Fed the ammunition, the cover that it needs, to not raise interest rates too quickly. And I think Jay Powell is a very tepid sort of inflation fighter and he's not going to do as much as he needs to do to get that under control. And this seems like an excuse to kick the can further down the road still and not do too much too soon."
from jp


Telegram Type Driven Thoughts 🦀
FROM American