{"id":15496990,"url":"https://github.com/lencx/learn-rust","last_synced_at":"2026-02-25T09:35:35.102Z","repository":{"id":104825411,"uuid":"161990570","full_name":"lencx/learn-rust","owner":"lencx","description":"🦀 Learning Rust","archived":false,"fork":false,"pushed_at":"2020-10-24T13:48:49.000Z","size":286,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T17:46:50.497Z","etag":null,"topics":["chapters","example","rust"],"latest_commit_sha":null,"homepage":"https://www.rust-lang.org","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lencx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-16T10:35:14.000Z","updated_at":"2025-06-03T07:36:54.000Z","dependencies_parsed_at":"2023-05-30T08:15:51.742Z","dependency_job_id":null,"html_url":"https://github.com/lencx/learn-rust","commit_stats":{"total_commits":70,"total_committers":1,"mean_commits":70.0,"dds":0.0,"last_synced_commit":"54d73aa8b39562dc6aca0a37aa6be1bacf2dfd1a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lencx/learn-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Flearn-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Flearn-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Flearn-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Flearn-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lencx","download_url":"https://codeload.github.com/lencx/learn-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Flearn-rust/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29816159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["chapters","example","rust"],"created_at":"2024-10-02T08:29:49.920Z","updated_at":"2026-02-25T09:35:35.081Z","avatar_url":"https://github.com/lencx.png","language":"Rust","readme":"# Rust Learn\n\n## Start\n\n### Install\n\n```bash\n# installing `rustup` on Linux or macOS\ncurl https://sh.rustup.rs -sSf | sh\n\nexport PATH=\"$HOME/.cargo/bin:$PATH\"\n```\n\n### Updating \u0026 Uninstalling\n\n```bash\nrustup update\n\nrustup self uninstall\n```\n\n### Troubleshooting\n\n```bash\nrustc\n\nrustup\n\ncargo\ncargo new\ncargo check\ncargo run\ncargo build [--release]\ncargo doc [--open]\ncargo test\n\n# If you don’t want to run the tests in parallel\n# or if you want more fine-grained control over the number of threads used\n# We set the number of test threads to 1, telling the program not to use any parallelism.\ncargo test -- --test-threads=1\n\n# disable the output capture behavior\ncargo test -- --nocapture\n\n# Filtering to Run Multiple Tests\n# note that the module in which a test appears becomes part of the test’s name,\n# so we can run all the tests in a module by filtering on the module’s name.\ncargo test \u003cfn_part_name\u003e\n\n# run only the ignored tests\ncargo test -- --ignored\n\n# to run all the tests in a particular integration test file\ncargo test --test \u003cfilename\u003e\n\n# run tests for one particular crate in a workspace from the top-level directory\ncargo test -p \u003ccrate_name\u003e\n\ncargo login \u003cAPI_TOKEN\u003e\ncargo publish\n# `--undo`: By adding `--undo` to the command, you can also undo a yank and allow projects to start depending on a version again\ncargo yank --vers \u003cversion\u003e [--undo]\n\ncargo install \u003cbinary_crate\u003e\n```\n\n\u003e [Cargo.toml](https://doc.rust-lang.org/cargo/reference/manifest.html)\n\n```toml\n[package]\nname = \"pack_name\" # the name of the package\nversion = \"pack_version\" # the current version, obeying semver\nauthors = [\"name \u003cemail@example.com\u003e\"]\nedition = \"2018\"\n\n[profile.dev]\nopt-level = 0\n\n[profile.release]\nopt-level = 3\n\n[dependencies]\n\n[workspace]\nmembers = [\"...\"]\n```\n\n### Local Documentation\n\n```bash\nrustup doc\n```\n\n## Data Types\n\n* Integer Types\n\n  | Length  | Signed | Unsigned |\n  | ------- | ------ | -------- |\n  | 8-bit   | i8     | u8       |\n  | 16-bit  | i16    | u16      |\n  | 32-bit  | i32    | u32      |\n  | 64-bit  | i64    | u64      |\n  | 128-bit | i128   | u128     |\n  | arch    | isize  | usize    |\n\n  * signed: **-2\u003csup\u003en-1\u003c/sup\u003e ～ 2\u003csup\u003en-1\u003c/sup\u003e-1**\n  * unsigned: **0 ～ 2\u003csup\u003en\u003c/sup\u003e-1**\n  * `isize` \u0026 `usize`: 64 bits *(64-bit architecture)*, 32 bits *(32-bit architecture)*\n\n* Floating-Point Types\n\n\u003e `f32`, `f64`(default): The `f32` type is a single-precision float, and `f64` has double precision.\n\n* The Boolean Type: `bool`\n\n* The Character Type: `char`\n\n* Compound Types:\n\n  * The Tuple Type: `tuple`\n\n   \u003e `tuple`: A finite heterogeneous sequence, (T, U, ..).\n\n  * The Array Type: `array` `slice`\n\n   \u003e `array`: A fixed-size array, denoted `[T; N]`, for the element type, `T`, and the non-negative compile-time    constant size, `N`.\n\n   \u003e `slice`: A dynamically-sized view into a contiguous sequence, `[T]`.\n\n## Documentation\n\n\u003e Documentation comments within items are useful for describing crates and modules especially. Use them to explain the overall purpose of the container to help your users understand the crate’s organization.\n\n* `///`: documentation comments, support Markdown notation for formatting the text.\n* `//!`: adds documentation to the item that contains the comments rather than adding documentation to the items following the comments.\n\n\u003e **Commonly Used Sections**\n\n* `Panics`: The scenarios in which the function being documented could panic. Callers of the function who don’t want their programs to panic should make sure they don’t call the function in these situations.\n* `Errors`: If the function returns a `Result`, describing the kinds of errors that might occur and what conditions might cause those errors to be returned can be helpful to callers so they can write code to handle the different kinds of errors in different ways.\n* `Safety`: If the function is `unsafe` to call, there should be a section explaining why the function is unsafe and covering the invariants that the function expects callers to uphold.\n\n## Attributes\n\n```rust\n/** syntax */\n// InnerAttribute:\n#![Attr]\n\n// OuterAttribute:\n#[Attr]\n```\n\n\u003ctable\u003e\n\u003cthead\u003e\n  \u003ctr\u003e\n    \u003cth\u003eBuilt-in attributes\u003c/th\u003e\n    \u003cth\u003eattribute\u003c/th\u003e\n    \u003cth\u003edescription\u003c/th\u003e\n  \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n  \u003c!-- Conditional compilation --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"2\"\u003eConditional compilation\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003ecfg\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003econtrols conditional compilation\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003ecfg_attr\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003econditionally includes attributes\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Testing --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"3\"\u003eTesting\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003etest\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003emarks a function as a test\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eignore\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edisables a test function\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eshould_panic\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eindicates a test should generate a panic.\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Testing --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"1\"\u003eDerive\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003ederive\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eautomatic trait implementations\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Macros --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"5\"\u003eMacros\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003emacro_export\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eexports a \u003ccode\u003emacro_rules\u003c/code\u003e macro for cross-crate usage\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003emacro_use\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eexpands macro visibility, or imports macros from other crates\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eproc_macro\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edefines a function-like macro\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eproc_macro_derive\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edefines a derive macro\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eproc_macro_attribute\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edefines an attribute macro\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Diagnostics --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"3\"\u003eDiagnostics\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003eallow, warn, deny, forbid\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003ealters the default lint level\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003edeprecated\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003egenerates deprecation notices\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003emust_use\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003egenerates a lint for unused values\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- ABI, linking, symbols, and FFI --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"11\"\u003eABI, linking, symbols, and FFI\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003elink\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies a native library to link with an \u003ccode\u003eextern\u003c/code\u003e block\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003elink_name\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the name of the symbol for functions or statics in an \u003ccode\u003eextern\u003c/code\u003e block\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eno_link\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eprevents linking an extern crate\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003erepr\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003econtrols type layout\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003ecrate_type\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the type of crate (library, executable, etc.)\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eno_main\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edisables emitting the main symbol\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eexport_name\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the exported symbol name for a function or static\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003elink_section\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the section of an object file to use for a function or static\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eno_mangle\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edisables symbol name encoding\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eused\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eforces the compiler to keep a static item in the output object file\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003ecrate_name\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the crate name\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Code generation --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"4\"\u003eCode generation\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003einline\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003ehint to inline code\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003ecold\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003ehint that a function is unlikely to be called\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eno_builtins\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edisables use of certain built-in functions\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003etarget_feature\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003econfigure platform-specific code generation\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Documentation --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"1\"\u003eDocumentation\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003edoc\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies documentation. See\n        \u003ca href=\"https://doc.rust-lang.org/rustdoc/the-doc-attribute.html\"\u003eThe Rustdoc Book\u003c/a\u003e\n        for more information.\n        \u003ca href=\"https://doc.rust-lang.org/reference/comments.html#doc-comments\"\u003eDoc comments\u003c/a\u003e\n        are transformed into \u003ccode\u003edoc\u003c/code\u003e attributes\n      \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Preludes --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"2\"\u003ePreludes\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003eno_std\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eremoves std from the prelude\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eno_implicit_prelude\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003edisables prelude lookups within a module\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Modules --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"1\"\u003eModules\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003epath\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the filename for a module\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Limits --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"2\"\u003eLimits\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003erecursion_limit\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003esets the maximum recursion limit for certain compile-time operations\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003etype_length_limit\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003esets the maximum size of a polymorphic type\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Runtime --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"3\"\u003eRuntime\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003epanic_handler\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003esets the function to handle panics\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003eglobal_allocator\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003esets the global memory allocator\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\u003cb\u003ewindows_subsystem\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003especifies the windows subsystem to link with\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003c!-- Features --\u003e\n  \u003ctr\u003e\n      \u003ctd rowspan=\"1\"\u003eFeatures\u003c/td\u003e\n      \u003ctd\u003e\u003cb\u003efeature\u003c/b\u003e\u003c/td\u003e\n      \u003ctd\u003eused to enable unstable or experimental compiler features. See\n        \u003ca href=\"https://doc.rust-lang.org/unstable-book/index.html\"\u003eThe Unstable Book\u003c/a\u003e\n        for features implemented in \u003ccode\u003erustc\u003c/code\u003e\n      \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n```rust\n/** Diagnostics */\n// overrides the check for C so that violations will go unreported\n#[allow(C)]\n// warns about violations of C but continues compilation\n#[warn(C)]\n// signals an error after encountering a violation of C\n#[deny(C)]\n// is the same as deny(C), but also forbids changing the lint level afterwards\n#[forbid(C)]\n// since: specifies a version number when the item was deprecated\n// note: specifies a string that should be included in the deprecation message\n#[deprecated(since = \"\", note=\"\")]\n// is used to issue a diagnostic warning when a value is not \"used\"\n#[must_use]\n\n\n/** Code generation */\n// suggests performing an inline expansion.\n#[inline]\n// suggests that an inline expansion should always be performed.\n#[inline(always)]\n// suggests that an inline expansion should never be performed.\n#[inline(never)]\n\n/** Testing */\n#[test]\n#[ignore]\n#[should_panic]\n```\n\n## Concept\n\n* `Object-Oriented`: Object-oriented programs are made up of objects. An object packages both data and the procedures that operate on that data. The procedures are typically called methods or operations.\n* `Polymorphism`: To many people, polymorphism is synonymous with inheritance. But it’s actually a more general concept that refers to code that can work with data of multiple types. For inheritance, those types are generally subclasses. \\\nRust instead uses generics to abstract over different possible types and trait bounds to impose constraints on what those types must provide. This is sometimes called bounded parametric polymorphism.\n\n## Related Links\n\n* [A closer look at Ownership in Rusts](https://blog.thoughtram.io/ownership-in-rust)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flencx%2Flearn-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flencx%2Flearn-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flencx%2Flearn-rust/lists"}