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

Apparently upbeat developments in Russia's discussions with Ukraine helped at least temporarily send investors back into risk assets. Russian President Vladimir Putin said during a meeting with his Belarusian counterpart Alexander Lukashenko that there were "certain positive developments" occurring in the talks with Ukraine, according to a transcript of their meeting. Putin added that discussions were happening "almost on a daily basis." Russian President Vladimir Putin launched Russia's invasion of Ukraine in the early-morning hours of February 24, targeting several key cities with military strikes. However, the perpetrators of such frauds are now adopting new methods and technologies to defraud the investors. The gold standard of encryption, known as end-to-end encryption, where only the sender and person who receives the message are able to see it, is available on Telegram only when the Secret Chat function is enabled. Voice and video calls are also completely encrypted. Stocks closed in the red Friday as investors weighed upbeat remarks from Russian President Vladimir Putin about diplomatic discussions with Ukraine against a weaker-than-expected print on U.S. consumer sentiment.
from id


Telegram Type Driven Thoughts 🦀
FROM American