Telegram Group & Telegram Channel
πŸ¦€ Zero-cost abstractions β€” ΠΌΠΈΡ„ ΠΈΠ»ΠΈ магия?

Одна ΠΈΠ· Π³Π»Π°Π²Π½Ρ‹Ρ… Ρ„ΠΈΡˆΠ΅ΠΊ Rust β€” zero-cost abstractions. Π—Π²ΡƒΡ‡ΠΈΡ‚ ΠΊΡ€ΡƒΡ‚ΠΎ, Π½ΠΎ Ρ‡Ρ‚ΠΎ это Π½Π° Π΄Π΅Π»Π΅?

πŸ“¦ Когда Ρ‚Ρ‹ пишСшь абстрактный ΠΊΠΎΠ΄ (Π΄ΠΆΠ΅Π½Π΅Ρ€ΠΈΠΊΠΈ, ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€Ρ‹, Ρ‚Ρ€Π΅ΠΉΡ‚Ρ‹), Ρ‚Ρ‹ ΠΎΠ±Ρ‹Ρ‡Π½ΠΎ ΠΏΠ»Π°Ρ‚ΠΈΡˆΡŒ Ρ†Π΅Π½ΠΎΠΉ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΠΈ. Но Π½Π΅ Π² Rust.

🧠 Rust-компилятор (LLVM) Π½Π° этапС компиляции ΠΌΠΎΠ½ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ (спСциализируСт) ΠΊΠΎΠ΄ β€” ΠΏΡ€Π΅Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΎΠ±ΠΎΠ±Ρ‰Ρ‘Π½Π½Ρ‹Π΅ конструкции Π² ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚Π½Ρ‹Π΅, Π° Π½Π΅Π½ΡƒΠΆΠ½Ρ‹Π΅ β€” Π²Ρ‹ΠΊΠΈΠ΄Ρ‹Π²Π°Π΅Ρ‚. Π’ ΠΈΡ‚ΠΎΠ³Π΅ Ρ‚Π²ΠΎΠΈ абстракции Π½Π΅ тормозят, Π° ΠΊΠΎΠ΄ остаётся Ρ‡ΠΈΡ‚Π°Π΅ΠΌΡ‹ΠΌ.

ΠŸΡ€ΠΈΠΌΠ΅Ρ€:

fn square<T: Copy + std::ops::Mul<Output = T>>(x: T) -> T {
x * x
}


Π’Π°ΠΊΠΎΠΉ ΠΊΠΎΠ΄ ΠΏΡ€ΠΈ компиляции становится ΠΎΠ±Ρ‹Ρ‡Π½ΠΎΠΉ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠ΅ΠΉ для i32, f64, ΠΈ Ρ‚Π°ΠΊ Π΄Π°Π»Π΅Π΅ β€” Π±Π΅Π· ΠΎΠ²Π΅Ρ€Ρ…Π΅Π΄Π°.

⚑️ Rust Π΄Π°Ρ‘Ρ‚ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΏΠΈΡΠ°Ρ‚ΡŒ Π²Ρ‹Ρ€Π°Π·ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ ΠΊΠΎΠ΄ Π±Π΅Π· страха ΠΏΠΎΡ‚Π΅Ρ€ΡΡ‚ΡŒ Π² пСрформансС. ИмСнно поэтому ΠΎΠ½ стал Π»ΡŽΠ±ΠΈΠΌΡ†Π΅ΠΌ систСмных Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊΠΎΠ², ΠΏΠΈΡˆΡƒΡ‰ΠΈΡ… ΠΈ ΠΏΠΎΠ΄ ΠΌΠΈΠΊΡ€ΠΎΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Ρ‹, ΠΈ ΠΏΠΎΠ΄ Π²Π΅Π±.

🧩 А Ρ‚Ρ‹ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΡˆΡŒ zero-cost ΠΏΠΎΠ΄Ρ…ΠΎΠ΄Ρ‹ Π² своём ΠΊΠΎΠ΄Π΅? Π”Π΅Π»ΠΈΡΡŒ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π°ΠΌΠΈ Π² коммСнтариях!

πŸ‘‰ @rust_lib



tg-me.com/rust_lib/234
Create:
Last Update:

πŸ¦€ Zero-cost abstractions β€” ΠΌΠΈΡ„ ΠΈΠ»ΠΈ магия?

Одна ΠΈΠ· Π³Π»Π°Π²Π½Ρ‹Ρ… Ρ„ΠΈΡˆΠ΅ΠΊ Rust β€” zero-cost abstractions. Π—Π²ΡƒΡ‡ΠΈΡ‚ ΠΊΡ€ΡƒΡ‚ΠΎ, Π½ΠΎ Ρ‡Ρ‚ΠΎ это Π½Π° Π΄Π΅Π»Π΅?

πŸ“¦ Когда Ρ‚Ρ‹ пишСшь абстрактный ΠΊΠΎΠ΄ (Π΄ΠΆΠ΅Π½Π΅Ρ€ΠΈΠΊΠΈ, ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€Ρ‹, Ρ‚Ρ€Π΅ΠΉΡ‚Ρ‹), Ρ‚Ρ‹ ΠΎΠ±Ρ‹Ρ‡Π½ΠΎ ΠΏΠ»Π°Ρ‚ΠΈΡˆΡŒ Ρ†Π΅Π½ΠΎΠΉ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΠΈ. Но Π½Π΅ Π² Rust.

🧠 Rust-компилятор (LLVM) Π½Π° этапС компиляции ΠΌΠΎΠ½ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ (спСциализируСт) ΠΊΠΎΠ΄ β€” ΠΏΡ€Π΅Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΎΠ±ΠΎΠ±Ρ‰Ρ‘Π½Π½Ρ‹Π΅ конструкции Π² ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚Π½Ρ‹Π΅, Π° Π½Π΅Π½ΡƒΠΆΠ½Ρ‹Π΅ β€” Π²Ρ‹ΠΊΠΈΠ΄Ρ‹Π²Π°Π΅Ρ‚. Π’ ΠΈΡ‚ΠΎΠ³Π΅ Ρ‚Π²ΠΎΠΈ абстракции Π½Π΅ тормозят, Π° ΠΊΠΎΠ΄ остаётся Ρ‡ΠΈΡ‚Π°Π΅ΠΌΡ‹ΠΌ.

ΠŸΡ€ΠΈΠΌΠ΅Ρ€:


fn square<T: Copy + std::ops::Mul<Output = T>>(x: T) -> T {
x * x
}


Π’Π°ΠΊΠΎΠΉ ΠΊΠΎΠ΄ ΠΏΡ€ΠΈ компиляции становится ΠΎΠ±Ρ‹Ρ‡Π½ΠΎΠΉ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠ΅ΠΉ для i32, f64, ΠΈ Ρ‚Π°ΠΊ Π΄Π°Π»Π΅Π΅ β€” Π±Π΅Π· ΠΎΠ²Π΅Ρ€Ρ…Π΅Π΄Π°.

⚑️ Rust Π΄Π°Ρ‘Ρ‚ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΏΠΈΡΠ°Ρ‚ΡŒ Π²Ρ‹Ρ€Π°Π·ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ ΠΊΠΎΠ΄ Π±Π΅Π· страха ΠΏΠΎΡ‚Π΅Ρ€ΡΡ‚ΡŒ Π² пСрформансС. ИмСнно поэтому ΠΎΠ½ стал Π»ΡŽΠ±ΠΈΠΌΡ†Π΅ΠΌ систСмных Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊΠΎΠ², ΠΏΠΈΡˆΡƒΡ‰ΠΈΡ… ΠΈ ΠΏΠΎΠ΄ ΠΌΠΈΠΊΡ€ΠΎΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Ρ‹, ΠΈ ΠΏΠΎΠ΄ Π²Π΅Π±.

🧩 А Ρ‚Ρ‹ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΡˆΡŒ zero-cost ΠΏΠΎΠ΄Ρ…ΠΎΠ΄Ρ‹ Π² своём ΠΊΠΎΠ΄Π΅? Π”Π΅Π»ΠΈΡΡŒ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π°ΠΌΠΈ Π² коммСнтариях!

πŸ‘‰ @rust_lib

BY Rust




Share with your friend now:
tg-me.com/rust_lib/234

View MORE
Open in Telegram


Rust Telegram | DID YOU KNOW?

Date: |

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.

Export WhatsApp stickers to Telegram on Android

From the Files app, scroll down to Internal storage, and tap on WhatsApp. Once you’re there, go to Media and then WhatsApp Stickers. Don’t be surprised if you find a large number of files in that folderβ€”it holds your personal collection of stickers and every one you’ve ever received. Even the bad ones.Tap the three dots in the top right corner of your screen to Select all. If you want to trim the fat and grab only the best of the best, this is the perfect time to do so: choose the ones you want to export by long-pressing one file to activate selection mode, and then tapping on the rest. Once you’re done, hit the Share button (that β€œless than”-like symbol at the top of your screen). If you have a big collectionβ€”more than 500 stickers, for exampleβ€”it’s possible that nothing will happen when you tap the Share button. Be patientβ€”your phone’s just struggling with a heavy load.On the menu that pops from the bottom of the screen, choose Telegram, and then select the chat named Saved messages. This is a chat only you can see, and it will serve as your sticker bank. Unlike WhatsApp, Telegram doesn’t store your favorite stickers in a quick-access reservoir right beside the typing field, but you’ll be able to snatch them out of your Saved messages chat and forward them to any of your Telegram contacts. This also means you won’t have a quick way to save incoming stickers like you did on WhatsApp, so you’ll have to forward them from one chat to the other.

Rust from ua


Telegram Rust
FROM USA