Telegram Group & Telegram Channel
Алиса копается
Загадка. Одна из этих строк не скомпилируется. Какая? let a1: _ = [b"a", b"a" as &[u8]]; let b1: _ = [b"a" as &[u8], b"a"]; let a2: [_; 2] = [b"a", b"a" as &[u8]]; let b2: [_; 2] = [b"a" as &[u8], b"a"]; let a3: [&[u8]; 2] = [b"a", b"a" as &[u8]]; let b3:…
&[T; N] автоматически умеет приводиться к &[T], поэтому третий код, конечно, работает в обеих вариациях.

Остается вопрос, что происходит при выводе типов. На практике оказывается, что b2 работает, а a2 не работает, т.е. тип элемента массива "жадно" выводится исходя из первого элемента. a1 и b1 по какой-то причине при этом оба работают. Таким образом, правильный ответ — a2.

Зная, что загвоздка в выводе типов заключается в приравнии типов, умеющих друг к другу coerce'иться, не в том порядке, угадайте, какие строки из следующих приведут к ошибке:

fn unify<T>(_x: T, _y: T) {}
unify(b"a", b"a" as &[u8]); // 1
unify(b"a" as &[u8], b"a"); // 2

if true { b"a" } else { b"a" as &[u8] }; // 3
if true { b"a" as &[u8] } else { b"a" }; // 4


Подсказка: true в if не влияет на вывод типов, с тем же успехом там могло быть любое другое условие.



group-telegram.com/alisa_rummages/187
Create:
Last Update:

&[T; N] автоматически умеет приводиться к &[T], поэтому третий код, конечно, работает в обеих вариациях.

Остается вопрос, что происходит при выводе типов. На практике оказывается, что b2 работает, а a2 не работает, т.е. тип элемента массива "жадно" выводится исходя из первого элемента. a1 и b1 по какой-то причине при этом оба работают. Таким образом, правильный ответ — a2.

Зная, что загвоздка в выводе типов заключается в приравнии типов, умеющих друг к другу coerce'иться, не в том порядке, угадайте, какие строки из следующих приведут к ошибке:

fn unify<T>(_x: T, _y: T) {}
unify(b"a", b"a" as &[u8]); // 1
unify(b"a" as &[u8], b"a"); // 2

if true { b"a" } else { b"a" as &[u8] }; // 3
if true { b"a" as &[u8] } else { b"a" }; // 4


Подсказка: true в if не влияет на вывод типов, с тем же успехом там могло быть любое другое условие.

BY Алиса копается


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

Share with your friend now:
group-telegram.com/alisa_rummages/187

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

In the past, it was noticed that through bulk SMSes, investors were induced to invest in or purchase the stocks of certain listed companies. "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." At this point, however, Durov had already been working on Telegram with his brother, and further planned a mobile-first social network with an explicit focus on anti-censorship. Later in April, he told TechCrunch that he had left Russia and had “no plans to go back,” saying that the nation was currently “incompatible with internet business at the moment.” He added later that he was looking for a country that matched his libertarian ideals to base his next startup. Overall, extreme levels of fear in the market seems to have morphed into something more resembling concern. For example, the Cboe Volatility Index fell from its 2022 peak of 36, which it hit Monday, to around 30 on Friday, a sign of easing tensions. Meanwhile, while the price of WTI crude oil slipped from Sunday’s multiyear high $130 of barrel to $109 a pop. Markets have been expecting heavy restrictions on Russian oil, some of which the U.S. has already imposed, and that would reduce the global supply and bring about even more burdensome inflation. Some people used the platform to organize ahead of the storming of the U.S. Capitol in January 2021, and last month Senator Mark Warner sent a letter to Durov urging him to curb Russian information operations on Telegram.
from ca


Telegram Алиса копается
FROM American