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: |

The news also helped traders look past another report showing decades-high inflation and shake off some of the volatility from recent sessions. The Bureau of Labor Statistics' February Consumer Price Index (CPI) this week showed another surge in prices even before Russia escalated its attacks in Ukraine. The headline CPI — soaring 7.9% over last year — underscored the sticky inflationary pressures reverberating across the U.S. economy, with everything from groceries to rents and airline fares getting more expensive for everyday consumers. During the operations, Sebi officials seized various records and documents, including 34 mobile phones, six laptops, four desktops, four tablets, two hard drive disks and one pen drive from the custody of these persons. Artem Kliuchnikov and his family fled Ukraine just days before the Russian invasion. In addition, Telegram now supports the use of third-party streaming tools like OBS Studio and XSplit to broadcast live video, allowing users to add overlays and multi-screen layouts for a more professional look. Despite Telegram's origins, its approach to users' security has privacy advocates worried.
from ua


Telegram Type Driven Thoughts 🦀
FROM American