Rust has gained traction in the technical community as a safe system programming language. A unique feature of Rust is the memory ownership model, which enforces memory safety at compile-time. This project investigated how the memory model is used in practice. This report defines patterns that categorize the usage of variables with owned values in Rust. An automated analysis was used to scan over 3 million function bodies with over 7 million owned variables from 8 951 open-source projects. The analysis indicates that only 18% of all owned variables are borrowed at one point. In fact, only 61% of all analyzed function bodies contained at least one borrow. The data indicates that owned values are either mutable or immutably borrowed, only 0.6% of the analyzed variables had both borrow kinds in the same scope. Another interesting observation is that most values are moved instead of dropped at the end of their scope.
Identifer | oai:union.ndltd.org:UPSALLA1/oai:DiVA.org:uu-532329 |
Date | January 2024 |
Creators | Stoldt, Fridtjof Peer |
Publisher | Uppsala universitet, Institutionen för informationsteknologi |
Source Sets | DiVA Archive at Upsalla University |
Language | English |
Detected Language | English |
Type | Student thesis, info:eu-repo/semantics/bachelorThesis, text |
Format | application/pdf |
Rights | info:eu-repo/semantics/openAccess |
Relation | IT ; IT mDV 24 011 |
Page generated in 0.0016 seconds