{"id":13595655,"url":"https://github.com/nrc/r4cppp","last_synced_at":"2025-05-14T16:01:49.572Z","repository":{"id":27606216,"uuid":"31089811","full_name":"nrc/r4cppp","owner":"nrc","description":"Rust for C++ programmers","archived":false,"fork":false,"pushed_at":"2024-05-16T20:56:44.000Z","size":512,"stargazers_count":3705,"open_issues_count":57,"forks_count":294,"subscribers_count":96,"default_branch":"master","last_synced_at":"2025-04-05T19:05:32.559Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nrc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-20T23:13:12.000Z","updated_at":"2025-03-29T00:52:40.000Z","dependencies_parsed_at":"2023-02-18T00:40:21.150Z","dependency_job_id":"a016ffea-6fab-44d2-90fe-2febf1611917","html_url":"https://github.com/nrc/r4cppp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrc%2Fr4cppp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrc%2Fr4cppp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrc%2Fr4cppp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrc%2Fr4cppp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nrc","download_url":"https://codeload.github.com/nrc/r4cppp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631602,"owners_count":21136553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:01:54.684Z","updated_at":"2025-04-12T20:37:49.297Z","avatar_url":"https://github.com/nrc.png","language":"Rust","readme":"# Rust For Systems Programmers\n\nA Rust tutorial for experienced C and C++ programmers.\n\nJump to [contents](#contents).\nJump to [contributing](#contributing).\n\nThis tutorial is intended for programmers who already know how pointers and\nreferences work and are used to systems programming concepts such as integer\nwidths and memory management. We intend to cover, primarily, the differences\nbetween Rust and C++ to get you writing Rust programs quickly without lots of\nfluff you probably already know.\n\nHopefully, Rust is a pretty intuitive language for C++ programmers. Most of the\nsyntax is pretty similar. The big difference (in my experience) is that the\nsometimes vague concepts of good systems programming are strictly enforced by\nthe compiler. This can be infuriating at first - there are things you want to\ndo, but the compiler won't let you (at least in safe code), and sometimes these\nthings *are* safe, but you can't convince the compiler of that. However, you'll\nquickly develop a good intuition for what is allowed. Communicating your own\nnotions of memory safety to the compiler requires some new and sometimes\ncomplicated type annotations. But if you have a strong idea of lifetimes for\nyour objects and experience with generic programming, they shouldn't be too\ntough to learn.\n\nThis tutorial started as a [series of blog posts](http://featherweightmusings.blogspot.co.nz/search/label/rust-for-c).\nPartly as an aid for me (@nrc) learning Rust (there is no better way to\ncheck that you have learnt something than to try and explain it to somebody\nelse) and partly because I found the existing resources for learning Rust\nunsatisfactory - they spent too much time on the basics that I already knew and\nused higher level intuitions to describe concepts that could better be explained\nto me using lower level intuitions. Since then, the documentation for Rust has\ngot *much* better, but I still think that existing C++ programmers are an\naudience who are a natural target for Rust, but are not particularly well\ncatered for.\n\n\n## Contents\n\n1. [Introduction - Hello world!](hello-world.md)\n1. [Control flow](control-flow.md)\n1. [Primitive types and operators](primitives.md)\n1. [Unique pointers](unique.md)\n1. [Borrowed pointers](borrowed.md)\n1. [Rc and raw pointers](rc-raw.md)\n1. [Data types](data-types.md)\n1. [Destructuring pt 1](destructuring.md)\n1. [Destructuring pt 2](destructuring-2.md)\n1. [Arrays and vecs](arrays.md)\n1. [Graphs and arena allocation](graphs/README.md)\n1. [Closures and first-class functions](closures.md)\n\n\n## Other resources\n\n* [The Rust book/guide](http://doc.rust-lang.org/book/) - the best place for\n  learning Rust in general and probably the best place to go for a second opinion\n  on stuff here or for stuff not covered.\n* [Rust API documentation](http://doc.rust-lang.org/std/index.html) - detailed\n  documentation for the Rust libraries.\n* [The Rust reference manual](https://doc.rust-lang.org/reference/) - a little\n  out of date in places, but thorough; good for looking up details.\n* [Discuss forum](http://users.rust-lang.org/) - general forum for discussion or\n  questions about using and learning Rust.\n* [StackOverflow Rust questions](https://stackoverflow.com/questions/tagged/rust) - answers\n  to many beginner and advanced questions about Rust, but be careful though - Rust\n  has changed *a lot* over the years and some of the answers might be very out of date.\n* [A Firehose of Rust](https://www.youtube.com/watch?v=IPmRDS0OSxM) - a recorded talk\n  introducing C++ programmers to how lifetimes, mutable aliasing, and move semantics work\n  in Rust\n\n\n## Contributing\n\nYes please!\n\nIf you spot a typo or mistake, please submit a PR, don't be shy! Please feel\nfree to file [an issue](https://github.com/nrc/r4cppp/issues/new) for\nlarger changes or for new chapters you'd like to see. I'd also be happy to see\nre-organisation of existing work or expanded examples, if you feel the tutorial\ncould be improved in those ways.\n\nIf you'd like to contribute a paragraph, section, or chapter please do! If you\nwant ideas for things to cover, see the [list of issues](https://github.com/nrc/r4cppp/issues),\nin particular those tagged [new material](https://github.com/nrc/r4cppp/labels/new%20material).\nIf you're not sure of something, please get in touch by pinging me here\n(@nrc) or on irc (nrc, on #rust or #rust-internals).\n\n\n### Style\n\nObviously, the intended audience is C++ programmers. The tutorial should\nconcentrate on things that will be new to experienced C++ programmers, rather\nthan a general audience (although, I don't assume the audience is familiar with\nthe most recent versions of C++). I'd like to avoid too much basic material and\ndefinitely avoid too much overlap with other resources, in particular the Rust\nguide/book.\n\nWork on edge case use cases (e.g., using a different build system from Cargo, or\nwriting syntax extensions, using unstable APIs) is definitely welcome, as is\nin-depth work on topics already covered at a high level.\n\nI'd like to avoid recipe-style examples for converting C++ code to Rust code,\nbut small examples of this kind are OK.\n\nUse of different formats (e.g., question and answer/FAQs, or larger worked\nexamples) are welcome.\n\nI don't plan on adding exercises or suggestions for mini-projects, but if you're\ninterested in that, let me know.\n\nI'm aiming for a fairly academic tone, but not too dry. All writing should be in\nEnglish (British English, not American English; although I would be very happy\nto have localisations/translations into any language, including American\nEnglish) and be valid GitHub markdown. For advice on writing style, grammar,\npunctuation, etc. see the Oxford Style Manual\nor [The Economist Style Guide](http://www.economist.com/styleguide/introduction).\nPlease limit width to 80 columns. I am a fan of the Oxford comma.\n\nDon't feel like work has to be perfect to be submitted, I'm happy to edit and\nI'm sure other people will be in the future.\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrc%2Fr4cppp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrc%2Fr4cppp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrc%2Fr4cppp/lists"}