Rust

RAII in Rust

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Në Rust, çdo burim (skedar, lock, lidhje) lirohet automatikisht kur vlera del nga fusha — pa free(), close() ose finally. Kjo ide quhet RAII dhe e huazuar nga C++.

EnglishEN

In Rust, every resource (file, lock, connection) is released automatically when the value goes out of scope — no free(), close() or finally. This idea is called RAII, borrowed from C++.

Si ta mendosh

Si dera që mbyllet vetë kur del nga dhoma.

Lexoje në anglisht

Like a door that closes itself when you leave the room.

Shembull kodirust

{
    let f = File::create("shenime.txt")?;
    // ... shkruaj
}   // skedari mbyllet këtu automatikisht

Terma të lidhur