[{"data":1,"prerenderedAt":817},["ShallowReactive",2],{"/en-us/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started":3,"navigation-en-us":43,"banner-en-us":454,"footer-en-us":464,"blog-post-authors-en-us-Michael Friedrich":704,"blog-related-posts-en-us-learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started":718,"blog-promotions-en-us":755,"next-steps-en-us":807},{"id":4,"title":5,"authorSlugs":6,"authors":8,"body":10,"category":11,"categorySlug":11,"config":12,"content":16,"date":20,"description":17,"extension":27,"externalUrl":28,"featured":14,"heroImage":19,"isFeatured":14,"meta":29,"navigation":30,"path":31,"publishedDate":20,"rawbody":32,"seo":33,"slug":13,"stem":37,"tagSlugs":38,"tags":41,"template":15,"updatedDate":28,"__hash__":42},"blogPosts/en-us/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started.yml","Learning Rust with a little help from AI",[7],"michael-friedrich",[9],"Michael Friedrich","Learning a new programming language can help broaden your software development expertise, open career opportunities, or create fun challenges. However, it can be difficult to decide on one specific approach to learning a new language. Artificial intelligence (AI) can help. In this tutorial, you'll learn how to leverage AI-powered GitLab Duo Code Suggestions for a guided experience in learning the Rust programming language.\n\n- [Preparations](#preparations)\n  - [VS Code](#vs-code)\n  - [Code Suggestions](#code-suggestions)\n- [Learning a new programming language: Rust](#learning-a-new-programming-language-rust)\n    - [Development environment for Rust](#development-environment-for-rust)\n    - [Hello, World](#hello-world)\n- [Cargo: Bringing structure into Rust](#cargo-bringing-structure-into-rust)\n- [Automation: Configure CI/CD pipeline for Rust](#automation-configure-cicd-pipeline-for-rust)\n- [Continue learning Rust](#continue-learning-rust)\n    - [Define variables and print them](#define-variables-and-print-them)\n    - [Explore variable types](#explore-variable-types)\n    - [Flow control: Conditions and loops](#flow-control-conditions-and-loops)\n    - [Functions](#functions)\n    - [Testing](#testing)\n- [What is next](#what-is-next)\n    - [Async learning exercises](#async-learning-exercises)\n    - [Share your feedback](#share-your-feedback)\n\n## Preparations\nChoose your [preferred and supported IDE](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-in-other-ides-and-editors), and follow the documentation to enable code suggestions for [GitLab.com SaaS](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-on-gitlab-saas) or [GitLab self-managed instances](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-on-self-managed-gitlab).\n\nProgramming languages can require an install of the language interpreter command-line tools or compilers that generate binaries from source code to build and run the application.\n\nTip: You can also use [GitLab Remote Development workspaces](/blog/quick-start-guide-for-gitlab-workspaces/) to create your own cloud development environments, instead of local development environments. This blog post focuses on using VS Code and the GitLab Web IDE.\n\n### VS Code\nOn macOS, you can [install VS Code](https://code.visualstudio.com/download) as a Homebrew cask or manually download and install it.\n\n```shell\nbrew install --cask visual-studio-code\n```\n\nNavigate to the `Extensions` menu and search for `gitlab workflow`. Install the [GitLab workflow extension for VS Code](https://marketplace.visualstudio.com/items?itemName=GitLab.gitlab-workflow).\n\nTip: VS Code will also detect the programming languages, and offer to install additional plugins for syntax highlighting and development experience.\n\n### Code Suggestions\nIt can help to familiarize yourself with suggestions before actually verifying the suggestions. GitLab Code Suggestions are provided as you type, so you do not need use specific keyboard shortcuts. To accept a code suggestion, press the `tab` key. Also note that writing new code works more reliably than refactoring existing code. AI is non-deterministic, which means that the same suggestion may not be repeated after deleting the code suggestion. While Code Suggestions is in Beta, we are working on improving the accuracy of generated content overall. Please review the [known limitations](https://docs.gitlab.com/user/project/repository/code_suggestions/#known-limitations), as this could affect your learning experience.\n\n## Learning a new programming language: Rust\nNow, let's dig into learning Rust, which is one of the [supported languages in Code Suggestions](https://docs.gitlab.com/user/project/repository/code_suggestions/#supported-languages).\n\n[Rust by Example](https://doc.rust-lang.org/rust-by-example/) provides a great tutorial for beginners, together with the official [Rust book](https://doc.rust-lang.org/book/). The [Hands-on Rust book](https://hands-on-rust.com/) shows how to build a 2D game as a more practical approach. More examples are shared in [this Rust book list](https://github.com/sger/RustBooks).\n\nBefore diving into the source code, make sure to set up your development environment.\n\n### Development environment for Rust\n1) Create a new project `learn-rust-ai` in GitLab, and clone the project into your development environment. All code snippets are available in [this \"Learn Rust with AI\" project](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai).\n\n```shell\ngit clone https://gitlab.com/NAMESPACE/learn-rust-ai.git\n\ncd learn-rust-ai\n\ngit status\n```\n\n2) Install Rust and the build toolchain. Fortunately, this is straightforward [following the Rust install documentation](https://www.rust-lang.org/tools/install).\n\nTip for using the generic installer: Download the script and run it after review.\n\n```shell\n# Download and print the script before running it\ncurl -Lvs https://sh.rustup.rs -o rustup-init.sh\n\n# Run the Rust installer script\nsh rustup-init.sh\n```\n\nExample on macOS using Homebrew:\n\n```shell\nbrew install rust\n```\n\n1) Optional: Install the [rust-analyzer VS Code extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).\n\n2) Each exercise will invite you to compile the code with the [`rustc` command](https://doc.rust-lang.org/rustc/what-is-rustc.html), and later using [`cargo` as build tool and package manager](https://doc.rust-lang.org/cargo/index.html).\n\nYou are all set to learn Rust!\n\n### Hello, World\nWe will start with [Rust by Example](https://doc.rust-lang.org/rust-by-example/), and follow the [Hello, World exercise](https://doc.rust-lang.org/rust-by-example/hello.html).\n\nCreate a new file `hello.rs` in the root directory of the project and start with a comment saying `// Hello world`. Next, start writing the `main` function, and verify the code suggestion.\n\n![VS Code hello.rs Rust code suggestion, asking to accept](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_suggested.png)\n\nAccept the suggestion by pressing the `tab` key and save the file (keyboard shortcut: cmd s).\n\n```text\n// Hello world\n\nfn main() {\n    println!(\"Hello, world!\");\n}\n```\n\n![VS Code hello.rs Rust code suggestion, accepted](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_accepted.png)\n\nCommit the change to the Git repository. In VS Code, use the keyboard shortcut `ctrl shift G`, add a commit message, and hit `cmd enter` to submit.\n\nUse the command palette (`cmd shift p`) and search for `create terminal` to open a new terminal.\n\nBuild and run the code.\n\n```shell\nrustc hello.rs\n\n./hello\n```\n\n![hello.rs Rust code suggestion, accepted, compiled, run](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_cli_build.png)\n\nTip: Adding [code comments in Rust (`//`)](https://doc.rust-lang.org/reference/comments.html) before you start writing a function or algorithm will help Code Suggestions with more context to provide better suggestions. In the example above, we did that with `// Hello world`, and will continue doing so in the next exercises.\n\n## Cargo: Bringing structure into Rust\n[Cargo](https://doc.rust-lang.org/rust-by-example/cargo.html) is the official Rust package management tool. It is more than that - you can run build and test commands because Cargo understands them as well.\n\nYou can initialize a new Cargo configuration in the current directory tree with the following command:\n\n```shell\ncargo init\n```\n\nThe directory tree invites you to add the source code into the `src/` directory, while `Cargo.toml` manages the dependencies and used compiler versions. The `.gitignore` file is also added including best practices.\n\n```shell\ntree\n.\n├── Cargo.toml\n├── README.md\n├── hello\n├── hello.rs\n└── src\n    └── main.rs\n\n```\n\nTry building the code and running it using `cargo`.\n\n```shell\ncargo build\n\ncargo run\n```\n\nCommit all changes and push them to your GitLab project.\n\n```shell\ngit commit -avm \"Initialize Cargo\"\n\ngit push\n```\n\nAfter exploring Cargo, let's make sure that our code is continuously tested while learning Rust. The next section explains how to set up [GitLab CI/CD](https://about.gitlab.com/topics/ci-cd/) for Rust.\n\n## Automation: Configure CI/CD pipeline for Rust\nThe [CI/CD pipeline](https://docs.gitlab.com/ci/) should run two jobs in two stages: Build and test the code. The default container [image](https://docs.gitlab.com/ci/yaml/#image), `rust:latest`, works in the first iteration. In order to save resources, the CI/CD configuration also supports [caching](https://docs.gitlab.com/ci/caching/) for downloaded dependencies and build objects. The `CARGO_HOME` variable is set to the CI/CD job home directory to ensure everything gets appropriately cached.\n\n```yaml\nstages:\n  - build\n  - test\n\ndefault:\n  image: rust:latest\n  cache:\n    key: ${CI_COMMIT_REF_SLUG}\n    paths:\n      - .cargo/bin\n      - .cargo/registry/index\n      - .cargo/registry/cache\n      - target/debug/deps\n      - target/debug/build\n    policy: pull-push\n\n# Cargo data needs to be in the project directory to be cached.\nvariables:\n  CARGO_HOME: ${CI_PROJECT_DIR}/.cargo\n\n```\n\nThe CI/CD jobs inherit the [`default`](https://docs.gitlab.com/ci/yaml/#default) values, and specify the cargo commands in the [`script` section](https://docs.gitlab.com/ci/yaml/#script).\n\n```yaml\nbuild-latest:\n  stage: build\n  script:\n    - cargo build --verbose\n\ntest-latest:\n  stage: build\n  script:\n    - cargo test --verbose\n\n```\n\nYou can see an example in [this MR](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/merge_requests/1/diffs).\n\n## Continue learning Rust\nMake sure to add new source code into the `src/` directory.\n\n### Define variables and print them\nPractice adding a few more [print](https://doc.rust-lang.org/rust-by-example/hello/print.html) statements into `src/main.rs`, and then build and run the code again.\n\n1) Define a variable called `name` and assign your name as string value.\n\n2) Print the name, including a string prefix saying `Hello, `.\n\n![VS Code main.rs Rust code suggestion, first step in print](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_first.png)\n\n![VS Code main.rs Rust code suggestion, second step in print](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_second.png)\n\n1) Open a new terminal in VS Code using the command palette (keyboard shortcut `cmd + shift + p`) and search for `terminal`.\n\n2) Build and run the code with the `cargo build` and `cargo run` commands.\n\n![VS Code terminal with cargo build and run output](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_cargo_build_run_terminal.png)\n\nAn example solution can be found [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/variable_print.rs).\n\n### Explore variable types\nDefine different variable value types ([primitives](https://doc.rust-lang.org/rust-by-example/primitives.html)) and embed them into the `print` statements. Maybe they feel familiar with other programming languages?\n\nTip: Use code comments to see which code suggestions can be useful to learn. Start with typing `// Integer addition` and see what code suggestions you can add.\n\n![VS Code main.rs Rust code suggestion, primitive types with literals and expressions](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_primitive_types_literals_operators.png)\n\nExperiment with GitLab Duo Code Suggestions. The shown examples are non-deterministic, but you may be able to add additions, subscriptions, multiplications, etc., and the corresponding `println` statements just by accepting code suggestions and continuing the flow with `enter` or completing the code statements. This workflow can create a chain of code suggestions that can help you learn the Rust language.\n\n![Literals and expressions, first suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_01.png)\n![Literals and expressions, second suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_02.png)\n![Literals and expressions, third suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_03.png)\n\nAn example solution can be found [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/literals_expressions.rs).\n\nThe code suggestions are not perfect. Sometimes there are errors that require you to fix the problems. When writing this blog post, I had to fix two missing semicolons at the end of the code lines. The great thing about the Rust compiler is that the error messages tell you exactly where the problem happens with suggestions to fix them. Code Suggestions and the Rust-provided build chain make writing Rust code more efficient.\n\n```rust\nprintln!(\"Hello, {}!\", name)\n\n// Integer subtraction\nlet y = 9 - 4\n```\n\n![Terminal build, errors, Rust compiler help](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_terminal_errors_rust_help.png)\n\nYou can try to provoke the same error by removing a semicolon at the end of a statement and then running `cargo build` in the terminal again. The Rust compiler will also warn you about unused variables to help with better code quality. The screenshot shows warnings for variable definitions, and also a CLI command to fix them.\n\n![Terminal build, warnings, Rust compiler help](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_terminal_warnings_rust_help.png)\n\n### Flow control: Conditions and loops\nNext, let's focus on [flow control](https://doc.rust-lang.org/rust-by-example/flow_control.html) with conditions, loops, etc., and how to implement them.\n\n1) Start typing `// Flow control` and see which suggestions are provided.\n\n2) Experiment with the code, and continue defining a boolean variable `v` which is set to true.\n\n```rust\n\n  // Flow control\n  let v = true;\n\n```\n\n![Conditions, boolean variable](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_conditions_01.png)\n![Conditions, boolean variable, if condition](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_conditions_02.png)\n\n1) Start typing `// Loops` and experiment with the code suggestions.\n\nLet's assume the loop looks the like following snippet. It does not have a loop counter which gets printed on every loop execution.\n\n```rust\n// Loops\nlet mut count = 0;\n\nloop {\n    count += 1;\n\n    if count == 10 {\n        break;\n    }\n}\n```\n\n2) Start typing `println!` and see which code suggestions are provided, for example `println!(\"Count: {}\", count);`.\n\n![Loops, loop counter print suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_loops_print_counter.png)\n\n3) Apply the suggestions, and execute `cargo build && cargo run` on the terminal again.\n\nLet's learn more: Rust supports different loop types, for example [while loops](https://doc.rust-lang.org/rust-by-example/flow_control/while.html), [for loops](https://doc.rust-lang.org/rust-by-example/flow_control/for.html), etc.\n\n1) Type `// While loop` and verify the code suggestions. Repeat the same for `// For loop`.\n\n```rust\n// While loops\nlet mut count = 0;\n\nwhile count \u003C 10 {\n    count += 1;\n    println!(\"Count: {}\", count);\n}\n\n// For loops\nlet a = [10, 2, 3, 4, 5];\n\nfor element in a {\n    println!(\"Element: {}\", element);\n}\n```\n\nThere is more to learn with loops and conditions: Iterate over arrays, lists, maps, slices. Practice with writing comments for `// Maps and sets` and `// Vectors and strings`.\n\n![Vectors, strings](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_vectors_strings.png)\n\n```rust\n\n  // Maps and sets\n  let mut scores = HashMap::new();\n\n  scores.insert(String::from(\"Blue\"), 10);\n  scores.insert(String::from(\"Yellow\"), 50);\n\n  for (key, value ) in &scores {\n      println!(\"{}: {}\", key, value);\n  }\n\n  // Vectors and strings\n  let mut v = Vec::new();\n\n  v.push(1);\n  v.push(2);\n\n  for element in &v {\n      println!(\"Element: {}\", element);\n  }\n\n```\n\nThis snippet will fail because the `HashMap` type needs to be imported from `std::collections::HashMap`. Add the following line on top before the main function definition:\n\n```rust\nuse std::collections::HashMap;\n```\n\n2) Build and run the code with `cargo build && cargo run`.\n\nAn example solution is provided [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/flow_control.rs).\n\n**Async exercise**:\n\n1) Modify the input values for the different data types, and build and run the code again.\n\n2) Add a condition into the loops that print the items only when a specific condition is met (for example, the number is odd or even).\n\n### Functions\n\n[Functions](https://doc.rust-lang.org/rust-by-example/fn.html) help increase code readability and testability with unit tests. Practice creating functions with the following steps:\n\n1) Two functions `isEven` and `isOdd` to evaluate whether a number is even or odd.\n\n```rust\nfn isEven(x: i32) -> bool {\n    x % 2 == 0\n}\n\nfn isOdd(x: i32) -> bool {\n    x % 2 != 0\n}\n```\n\n2) `isPrime` function to check whether a given integer value is a prime number.\n\n```rust\nfn isPrime(x: i32) -> bool {\n    let mut i = 2;\n\n    while i * i \u003C= x {\n        if x % i == 0 {\n            return false;\n        } else {\n            i += 1;\n        }\n    }\n\n    return true\n}\n```\n\n3) Create an array of integer values, loop over it, and call the functions. Let GitLab Code Suggestions guide you with the implementation by starting to type the if conditions followed by the function name.\n\n```rust\n\n  // Functions\n  let mut integers = vec![1, 2, 3, 4, 5];\n\n  for i in integers.iter() {\n\n      if (isEven(i)) {\n          println!(\"{} is even\", i);\n      }\n\n      if (isOdd(i)) {\n          println!(\"{} is odd\", i);\n      }\n\n      if (isPrime(i)) {\n          println!(\"{} is prime\", i);\n      }\n\n      println!(\"{}\", i);\n  }\n\n```\n\nNote that passing a reference value to a function may result in an error from the Rust compiler. Follow the suggestions and build the code again.\n\n```shell\n$ cargo build && cargo run\n\nerror[E0308]: mismatched types\n   --> src/main.rs:112:21\n    |\n112 |         if (isPrime(i)) {\n    |             ------- ^ expected `i32`, found `&{integer}`\n    |             |\n    |             arguments to this function are incorrect\n    |\nnote: function defined here\n   --> src/main.rs:136:4\n    |\n136 | fn isPrime(x: i32) -> bool {\n    |    ^^^^^^^ ------\nhelp: consider dereferencing the borrow\n    |\n112 |         if (isPrime(*i)) {\n    |                     +\n\n```\n\nAn example solution is provided [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/functions.rs).\n\n**Async exercise**: Create a function `containsString` and test it with an array of string values, and a string to search for, in a loop. The screenshot shows a potential implementation.\n\n![containsString function, and vector with string elements to test, suggesting its usage in the main function](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_function_implemented_then_suggested_in_main.png)\n\n### Testing\nWhile learning programming, adopt [testing](https://doc.rust-lang.org/rust-by-example/testing.html) into your process. This can be unit tests for functions, documentation testing, and integration testing. Practice with testing the previously created functions `isEven`, `isOdd`, and `isPrime`. Starty by typing `mod tests {` followed by a new line with `use super::*` to implement the example from the [Rust documentation for unit tests](https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html).\n\n```rust\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_is_even() {\n        assert!(isEven(2));\n        assert!(!isEven(3));\n    }\n\n    #[test]\n    fn test_is_odd() {\n        assert!(!isOdd(2));\n        assert!(isOdd(3));\n    }\n\n    #[test]\n    fn test_is_prime() {\n        assert!(isPrime(2));\n        assert!(!isPrime(3));\n    }\n}\n```\n\nRun `cargo test` to run the unit tests. Modify the test values to experiment with the results.\n\n```shell\ncargo test\n```\n\n![Function unit tests, cargo test output in the VS Code terminal](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_function_unit_tests_terminal_run.png)\n\nCreate unit tests that fail, and commit and push the changes to GitLab. The CI/CD pipelines will fail in this simulated breakage. The example above needs a fix for the `test_is_prime` test. Commit and push the change to verify that the pipeline passes again.\n\n```diff\n-        assert!(!isPrime(3));\n+        assert!(!isPrime(4));\n```\n\n## What is next\nIn an upcoming blog, we will look into advanced learning examples with asynchronous operations, services and external API communication in future blog posts. Until then, here are a few recommendations for practicing async.\n\n### Async learning exercises\n- [`std misc`](https://doc.rust-lang.org/rust-by-example/std_misc.html) provides asynchronous operations with threads, channels and file I/O\n- Book: [Hands-on Rust: Effective Learning through 2D Game Development and Play](https://pragprog.com/titles/hwrust/hands-on-rust/)\n- Tutorial: [Are we game yet?](https://arewegameyet.rs/resources/tutorials/)\n- Use case: [Web server with rocket.rs](https://rocket.rs/v0.5-rc/guide/quickstart/#running-examples)\n\nHere are a few more exercises and ideas for additional learning:\n1) The Rust compiler might have created warnings that need to be addressed. Follow the instructions from the `cargo build` commands and check the Git diff.\n\n```shell\ncargo fix --bin \"learn-rust-ai\"\n\ngit diff\n```\n\n2) [Error handling](https://doc.rust-lang.org/rust-by-example/error.html) is required when failure is detected, and the caller should know. Some errors can be recovered from within the application, others require program termination.\n\n3) The [`std` library](https://doc.rust-lang.org/rust-by-example/std.html) extends primitive types and makes programming more efficient.\n\n### Share your feedback\nWhich programming language are you learning or considering learning? Start a new topic on our [community](/community/) forum or Discord and share your experience.\n\nIf you are using Code Suggestions Beta with [GitLab Duo](/gitlab-duo-agent-platform/) already, please share your thoughts and feedback [in this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/405152).\n","ai-ml",{"slug":13,"featured":14,"template":15},"learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started",false,"BlogPost",{"title":5,"description":17,"authors":18,"heroImage":19,"date":20,"body":10,"category":11,"tags":21},"Use this guided tutorial, along with GitLab Duo Code Suggestions, to learn a new programming language.",[9],"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749663918/Blog/Hero%20Images/aipower.jpg","2023-08-10",[22,23,24,25,26],"DevSecOps","careers","tutorial","workflow","AI/ML","yml",null,{},true,"/en-us/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started","seo:\n  title: Learning Rust with a little help from AI\n  description: >-\n    Use this guided tutorial, along with GitLab Duo Code Suggestions, to learn a\n    new programming language.\n  ogTitle: Learning Rust with a little help from AI\n  ogDescription: >-\n    Use this guided tutorial, along with GitLab Duo Code Suggestions, to learn a\n    new programming language.\n  noIndex: false\n  ogImage: >-\n    https://res.cloudinary.com/about-gitlab-com/image/upload/v1749663918/Blog/Hero%20Images/aipower.jpg\n  ogUrl: >-\n    https://about.gitlab.com/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started\n  ogSiteName: https://about.gitlab.com\n  ogType: article\n  canonicalUrls: >-\n    https://about.gitlab.com/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started\ncontent:\n  title: Learning Rust with a little help from AI\n  description: >-\n    Use this guided tutorial, along with GitLab Duo Code Suggestions, to learn a\n    new programming language.\n  authors:\n    - Michael Friedrich\n  heroImage: >-\n    https://res.cloudinary.com/about-gitlab-com/image/upload/v1749663918/Blog/Hero%20Images/aipower.jpg\n  date: '2023-08-10'\n  body: >\n    Learning a new programming language can help broaden your software\n    development expertise, open career opportunities, or create fun challenges.\n    However, it can be difficult to decide on one specific approach to learning\n    a new language. Artificial intelligence (AI) can help. In this tutorial,\n    you'll learn how to leverage AI-powered GitLab Duo Code Suggestions for a\n    guided experience in learning the Rust programming language.\n\n\n    - [Preparations](#preparations)\n      - [VS Code](#vs-code)\n      - [Code Suggestions](#code-suggestions)\n    - [Learning a new programming language:\n    Rust](#learning-a-new-programming-language-rust)\n        - [Development environment for Rust](#development-environment-for-rust)\n        - [Hello, World](#hello-world)\n    - [Cargo: Bringing structure into Rust](#cargo-bringing-structure-into-rust)\n\n    - [Automation: Configure CI/CD pipeline for\n    Rust](#automation-configure-cicd-pipeline-for-rust)\n\n    - [Continue learning Rust](#continue-learning-rust)\n        - [Define variables and print them](#define-variables-and-print-them)\n        - [Explore variable types](#explore-variable-types)\n        - [Flow control: Conditions and loops](#flow-control-conditions-and-loops)\n        - [Functions](#functions)\n        - [Testing](#testing)\n    - [What is next](#what-is-next)\n        - [Async learning exercises](#async-learning-exercises)\n        - [Share your feedback](#share-your-feedback)\n\n    ## Preparations\n\n    Choose your [preferred and supported\n    IDE](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-in-other-ides-and-editors),\n    and follow the documentation to enable code suggestions for [GitLab.com\n    SaaS](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-on-gitlab-saas)\n    or [GitLab self-managed\n    instances](https://docs.gitlab.com/user/project/repository/code_suggestions/#enable-code-suggestions-on-self-managed-gitlab).\n\n\n    Programming languages can require an install of the language interpreter\n    command-line tools or compilers that generate binaries from source code to\n    build and run the application.\n\n\n    Tip: You can also use [GitLab Remote Development\n    workspaces](/blog/quick-start-guide-for-gitlab-workspaces/) to create your\n    own cloud development environments, instead of local development\n    environments. This blog post focuses on using VS Code and the GitLab Web\n    IDE.\n\n\n    ### VS Code\n\n    On macOS, you can [install VS Code](https://code.visualstudio.com/download)\n    as a Homebrew cask or manually download and install it.\n\n\n    ```shell\n\n    brew install --cask visual-studio-code\n\n    ```\n\n\n    Navigate to the `Extensions` menu and search for `gitlab workflow`. Install\n    the [GitLab workflow extension for VS\n    Code](https://marketplace.visualstudio.com/items?itemName=GitLab.gitlab-workflow).\n\n\n    Tip: VS Code will also detect the programming languages, and offer to\n    install additional plugins for syntax highlighting and development\n    experience.\n\n\n    ### Code Suggestions\n\n    It can help to familiarize yourself with suggestions before actually\n    verifying the suggestions. GitLab Code Suggestions are provided as you type,\n    so you do not need use specific keyboard shortcuts. To accept a code\n    suggestion, press the `tab` key. Also note that writing new code works more\n    reliably than refactoring existing code. AI is non-deterministic, which\n    means that the same suggestion may not be repeated after deleting the code\n    suggestion. While Code Suggestions is in Beta, we are working on improving\n    the accuracy of generated content overall. Please review the [known\n    limitations](https://docs.gitlab.com/user/project/repository/code_suggestions/#known-limitations),\n    as this could affect your learning experience.\n\n\n    ## Learning a new programming language: Rust\n\n    Now, let's dig into learning Rust, which is one of the [supported languages\n    in Code\n    Suggestions](https://docs.gitlab.com/user/project/repository/code_suggestions/#supported-languages).\n\n\n    [Rust by Example](https://doc.rust-lang.org/rust-by-example/) provides a\n    great tutorial for beginners, together with the official [Rust\n    book](https://doc.rust-lang.org/book/). The [Hands-on Rust\n    book](https://hands-on-rust.com/) shows how to build a 2D game as a more\n    practical approach. More examples are shared in [this Rust book\n    list](https://github.com/sger/RustBooks).\n\n\n    Before diving into the source code, make sure to set up your development\n    environment.\n\n\n    ### Development environment for Rust\n\n    1) Create a new project `learn-rust-ai` in GitLab, and clone the project\n    into your development environment. All code snippets are available in [this\n    \"Learn Rust with AI\"\n    project](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai).\n\n\n    ```shell\n\n    git clone https://gitlab.com/NAMESPACE/learn-rust-ai.git\n\n\n    cd learn-rust-ai\n\n\n    git status\n\n    ```\n\n\n    2) Install Rust and the build toolchain. Fortunately, this is\n    straightforward [following the Rust install\n    documentation](https://www.rust-lang.org/tools/install).\n\n\n    Tip for using the generic installer: Download the script and run it after\n    review.\n\n\n    ```shell\n\n    # Download and print the script before running it\n\n    curl -Lvs https://sh.rustup.rs -o rustup-init.sh\n\n\n    # Run the Rust installer script\n\n    sh rustup-init.sh\n\n    ```\n\n\n    Example on macOS using Homebrew:\n\n\n    ```shell\n\n    brew install rust\n\n    ```\n\n\n    1) Optional: Install the [rust-analyzer VS Code\n    extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).\n\n\n    2) Each exercise will invite you to compile the code with the [`rustc`\n    command](https://doc.rust-lang.org/rustc/what-is-rustc.html), and later\n    using [`cargo` as build tool and package\n    manager](https://doc.rust-lang.org/cargo/index.html).\n\n\n    You are all set to learn Rust!\n\n\n    ### Hello, World\n\n    We will start with [Rust by\n    Example](https://doc.rust-lang.org/rust-by-example/), and follow the [Hello,\n    World exercise](https://doc.rust-lang.org/rust-by-example/hello.html).\n\n\n    Create a new file `hello.rs` in the root directory of the project and start\n    with a comment saying `// Hello world`. Next, start writing the `main`\n    function, and verify the code suggestion.\n\n\n    ![VS Code hello.rs Rust code suggestion, asking to\n    accept](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_suggested.png)\n\n\n    Accept the suggestion by pressing the `tab` key and save the file (keyboard\n    shortcut: cmd s).\n\n\n    ```text\n\n    // Hello world\n\n\n    fn main() {\n        println!(\"Hello, world!\");\n    }\n\n    ```\n\n\n    ![VS Code hello.rs Rust code suggestion,\n    accepted](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_accepted.png)\n\n\n    Commit the change to the Git repository. In VS Code, use the keyboard\n    shortcut `ctrl shift G`, add a commit message, and hit `cmd enter` to\n    submit.\n\n\n    Use the command palette (`cmd shift p`) and search for `create terminal` to\n    open a new terminal.\n\n\n    Build and run the code.\n\n\n    ```shell\n\n    rustc hello.rs\n\n\n    ./hello\n\n    ```\n\n\n    ![hello.rs Rust code suggestion, accepted, compiled,\n    run](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_hello_world_cli_build.png)\n\n\n    Tip: Adding [code comments in Rust\n    (`//`)](https://doc.rust-lang.org/reference/comments.html) before you start\n    writing a function or algorithm will help Code Suggestions with more context\n    to provide better suggestions. In the example above, we did that with `//\n    Hello world`, and will continue doing so in the next exercises.\n\n\n    ## Cargo: Bringing structure into Rust\n\n    [Cargo](https://doc.rust-lang.org/rust-by-example/cargo.html) is the\n    official Rust package management tool. It is more than that - you can run\n    build and test commands because Cargo understands them as well.\n\n\n    You can initialize a new Cargo configuration in the current directory tree\n    with the following command:\n\n\n    ```shell\n\n    cargo init\n\n    ```\n\n\n    The directory tree invites you to add the source code into the `src/`\n    directory, while `Cargo.toml` manages the dependencies and used compiler\n    versions. The `.gitignore` file is also added including best practices.\n\n\n    ```shell\n\n    tree\n\n    .\n\n    ├── Cargo.toml\n\n    ├── README.md\n\n    ├── hello\n\n    ├── hello.rs\n\n    └── src\n        └── main.rs\n\n    ```\n\n\n    Try building the code and running it using `cargo`.\n\n\n    ```shell\n\n    cargo build\n\n\n    cargo run\n\n    ```\n\n\n    Commit all changes and push them to your GitLab project.\n\n\n    ```shell\n\n    git commit -avm \"Initialize Cargo\"\n\n\n    git push\n\n    ```\n\n\n    After exploring Cargo, let's make sure that our code is continuously tested\n    while learning Rust. The next section explains how to set up [GitLab\n    CI/CD](https://about.gitlab.com/topics/ci-cd/) for Rust.\n\n\n    ## Automation: Configure CI/CD pipeline for Rust\n\n    The [CI/CD pipeline](https://docs.gitlab.com/ci/) should run two jobs in\n    two stages: Build and test the code. The default container\n    [image](https://docs.gitlab.com/ci/yaml/#image), `rust:latest`, works in\n    the first iteration. In order to save resources, the CI/CD configuration\n    also supports [caching](https://docs.gitlab.com/ci/caching/) for\n    downloaded dependencies and build objects. The `CARGO_HOME` variable is set\n    to the CI/CD job home directory to ensure everything gets appropriately\n    cached.\n\n\n    ```yaml\n\n    stages:\n      - build\n      - test\n\n    default:\n      image: rust:latest\n      cache:\n        key: ${CI_COMMIT_REF_SLUG}\n        paths:\n          - .cargo/bin\n          - .cargo/registry/index\n          - .cargo/registry/cache\n          - target/debug/deps\n          - target/debug/build\n        policy: pull-push\n\n    # Cargo data needs to be in the project directory to be cached.\n\n    variables:\n      CARGO_HOME: ${CI_PROJECT_DIR}/.cargo\n\n    ```\n\n\n    The CI/CD jobs inherit the\n    [`default`](https://docs.gitlab.com/ci/yaml/#default) values, and specify\n    the cargo commands in the [`script`\n    section](https://docs.gitlab.com/ci/yaml/#script).\n\n\n    ```yaml\n\n    build-latest:\n      stage: build\n      script:\n        - cargo build --verbose\n\n    test-latest:\n      stage: build\n      script:\n        - cargo test --verbose\n\n    ```\n\n\n    You can see an example in [this\n    MR](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/merge_requests/1/diffs).\n\n\n    ## Continue learning Rust\n\n    Make sure to add new source code into the `src/` directory.\n\n\n    ### Define variables and print them\n\n    Practice adding a few more\n    [print](https://doc.rust-lang.org/rust-by-example/hello/print.html)\n    statements into `src/main.rs`, and then build and run the code again.\n\n\n    1) Define a variable called `name` and assign your name as string value.\n\n\n    2) Print the name, including a string prefix saying `Hello, `.\n\n\n    ![VS Code main.rs Rust code suggestion, first step in\n    print](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_first.png)\n\n\n    ![VS Code main.rs Rust code suggestion, second step in\n    print](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_second.png)\n\n\n    1) Open a new terminal in VS Code using the command palette (keyboard\n    shortcut `cmd + shift + p`) and search for `terminal`.\n\n\n    2) Build and run the code with the `cargo build` and `cargo run` commands.\n\n\n    ![VS Code terminal with cargo build and run\n    output](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_print_variable_cargo_build_run_terminal.png)\n\n\n    An example solution can be found\n    [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/variable_print.rs).\n\n\n    ### Explore variable types\n\n    Define different variable value types\n    ([primitives](https://doc.rust-lang.org/rust-by-example/primitives.html))\n    and embed them into the `print` statements. Maybe they feel familiar with\n    other programming languages?\n\n\n    Tip: Use code comments to see which code suggestions can be useful to learn.\n    Start with typing `// Integer addition` and see what code suggestions you\n    can add.\n\n\n    ![VS Code main.rs Rust code suggestion, primitive types with literals and\n    expressions](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_primitive_types_literals_operators.png)\n\n\n    Experiment with GitLab Duo Code Suggestions. The shown examples are\n    non-deterministic, but you may be able to add additions, subscriptions,\n    multiplications, etc., and the corresponding `println` statements just by\n    accepting code suggestions and continuing the flow with `enter` or\n    completing the code statements. This workflow can create a chain of code\n    suggestions that can help you learn the Rust language.\n\n\n    ![Literals and expressions, first\n    suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_01.png)\n\n    ![Literals and expressions, second\n    suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_02.png)\n\n    ![Literals and expressions, third\n    suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_literals_expressions_03.png)\n\n\n    An example solution can be found\n    [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/literals_expressions.rs).\n\n\n    The code suggestions are not perfect. Sometimes there are errors that\n    require you to fix the problems. When writing this blog post, I had to fix\n    two missing semicolons at the end of the code lines. The great thing about\n    the Rust compiler is that the error messages tell you exactly where the\n    problem happens with suggestions to fix them. Code Suggestions and the\n    Rust-provided build chain make writing Rust code more efficient.\n\n\n    ```rust\n\n    println!(\"Hello, {}!\", name)\n\n\n    // Integer subtraction\n\n    let y = 9 - 4\n\n    ```\n\n\n    ![Terminal build, errors, Rust compiler\n    help](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_terminal_errors_rust_help.png)\n\n\n    You can try to provoke the same error by removing a semicolon at the end of\n    a statement and then running `cargo build` in the terminal again. The Rust\n    compiler will also warn you about unused variables to help with better code\n    quality. The screenshot shows warnings for variable definitions, and also a\n    CLI command to fix them.\n\n\n    ![Terminal build, warnings, Rust compiler\n    help](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_terminal_warnings_rust_help.png)\n\n\n    ### Flow control: Conditions and loops\n\n    Next, let's focus on [flow\n    control](https://doc.rust-lang.org/rust-by-example/flow_control.html) with\n    conditions, loops, etc., and how to implement them.\n\n\n    1) Start typing `// Flow control` and see which suggestions are provided.\n\n\n    2) Experiment with the code, and continue defining a boolean variable `v`\n    which is set to true.\n\n\n    ```rust\n\n      // Flow control\n      let v = true;\n\n    ```\n\n\n    ![Conditions, boolean\n    variable](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_conditions_01.png)\n\n    ![Conditions, boolean variable, if\n    condition](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_conditions_02.png)\n\n\n    1) Start typing `// Loops` and experiment with the code suggestions.\n\n\n    Let's assume the loop looks the like following snippet. It does not have a\n    loop counter which gets printed on every loop execution.\n\n\n    ```rust\n\n    // Loops\n\n    let mut count = 0;\n\n\n    loop {\n        count += 1;\n\n        if count == 10 {\n            break;\n        }\n    }\n\n    ```\n\n\n    2) Start typing `println!` and see which code suggestions are provided, for\n    example `println!(\"Count: {}\", count);`.\n\n\n    ![Loops, loop counter print\n    suggestion](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_loops_print_counter.png)\n\n\n    3) Apply the suggestions, and execute `cargo build && cargo run` on the\n    terminal again.\n\n\n    Let's learn more: Rust supports different loop types, for example [while\n    loops](https://doc.rust-lang.org/rust-by-example/flow_control/while.html),\n    [for\n    loops](https://doc.rust-lang.org/rust-by-example/flow_control/for.html),\n    etc.\n\n\n    1) Type `// While loop` and verify the code suggestions. Repeat the same for\n    `// For loop`.\n\n\n    ```rust\n\n    // While loops\n\n    let mut count = 0;\n\n\n    while count \u003C 10 {\n        count += 1;\n        println!(\"Count: {}\", count);\n    }\n\n\n    // For loops\n\n    let a = [10, 2, 3, 4, 5];\n\n\n    for element in a {\n        println!(\"Element: {}\", element);\n    }\n\n    ```\n\n\n    There is more to learn with loops and conditions: Iterate over arrays,\n    lists, maps, slices. Practice with writing comments for `// Maps and sets`\n    and `// Vectors and strings`.\n\n\n    ![Vectors,\n    strings](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_flow_control_vectors_strings.png)\n\n\n    ```rust\n\n      // Maps and sets\n      let mut scores = HashMap::new();\n\n      scores.insert(String::from(\"Blue\"), 10);\n      scores.insert(String::from(\"Yellow\"), 50);\n\n      for (key, value ) in &scores {\n          println!(\"{}: {}\", key, value);\n      }\n\n      // Vectors and strings\n      let mut v = Vec::new();\n\n      v.push(1);\n      v.push(2);\n\n      for element in &v {\n          println!(\"Element: {}\", element);\n      }\n\n    ```\n\n\n    This snippet will fail because the `HashMap` type needs to be imported from\n    `std::collections::HashMap`. Add the following line on top before the main\n    function definition:\n\n\n    ```rust\n\n    use std::collections::HashMap;\n\n    ```\n\n\n    2) Build and run the code with `cargo build && cargo run`.\n\n\n    An example solution is provided\n    [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/flow_control.rs).\n\n\n    **Async exercise**:\n\n\n    1) Modify the input values for the different data types, and build and run\n    the code again.\n\n\n    2) Add a condition into the loops that print the items only when a specific\n    condition is met (for example, the number is odd or even).\n\n\n    ### Functions\n\n\n    [Functions](https://doc.rust-lang.org/rust-by-example/fn.html) help increase\n    code readability and testability with unit tests. Practice creating\n    functions with the following steps:\n\n\n    1) Two functions `isEven` and `isOdd` to evaluate whether a number is even\n    or odd.\n\n\n    ```rust\n\n    fn isEven(x: i32) -> bool {\n        x % 2 == 0\n    }\n\n\n    fn isOdd(x: i32) -> bool {\n        x % 2 != 0\n    }\n\n    ```\n\n\n    2) `isPrime` function to check whether a given integer value is a prime\n    number.\n\n\n    ```rust\n\n    fn isPrime(x: i32) -> bool {\n        let mut i = 2;\n\n        while i * i \u003C= x {\n            if x % i == 0 {\n                return false;\n            } else {\n                i += 1;\n            }\n        }\n\n        return true\n    }\n\n    ```\n\n\n    3) Create an array of integer values, loop over it, and call the functions.\n    Let GitLab Code Suggestions guide you with the implementation by starting to\n    type the if conditions followed by the function name.\n\n\n    ```rust\n\n      // Functions\n      let mut integers = vec![1, 2, 3, 4, 5];\n\n      for i in integers.iter() {\n\n          if (isEven(i)) {\n              println!(\"{} is even\", i);\n          }\n\n          if (isOdd(i)) {\n              println!(\"{} is odd\", i);\n          }\n\n          if (isPrime(i)) {\n              println!(\"{} is prime\", i);\n          }\n\n          println!(\"{}\", i);\n      }\n\n    ```\n\n\n    Note that passing a reference value to a function may result in an error\n    from the Rust compiler. Follow the suggestions and build the code again.\n\n\n    ```shell\n\n    $ cargo build && cargo run\n\n\n    error[E0308]: mismatched types\n       --> src/main.rs:112:21\n        |\n    112 |         if (isPrime(i)) {\n        |             ------- ^ expected `i32`, found `&{integer}`\n        |             |\n        |             arguments to this function are incorrect\n        |\n    note: function defined here\n       --> src/main.rs:136:4\n        |\n    136 | fn isPrime(x: i32) -> bool {\n        |    ^^^^^^^ ------\n    help: consider dereferencing the borrow\n        |\n    112 |         if (isPrime(*i)) {\n        |                     +\n\n    ```\n\n\n    An example solution is provided\n    [here](https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai/-/blob/main/solutions/functions.rs).\n\n\n    **Async exercise**: Create a function `containsString` and test it with an\n    array of string values, and a string to search for, in a loop. The\n    screenshot shows a potential implementation.\n\n\n    ![containsString function, and vector with string elements to test,\n    suggesting its usage in the main\n    function](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_function_implemented_then_suggested_in_main.png)\n\n\n    ### Testing\n\n    While learning programming, adopt\n    [testing](https://doc.rust-lang.org/rust-by-example/testing.html) into your\n    process. This can be unit tests for functions, documentation testing, and\n    integration testing. Practice with testing the previously created functions\n    `isEven`, `isOdd`, and `isPrime`. Starty by typing `mod tests {` followed by\n    a new line with `use super::*` to implement the example from the [Rust\n    documentation for unit\n    tests](https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html).\n\n\n    ```rust\n\n    mod tests {\n        use super::*;\n\n        #[test]\n        fn test_is_even() {\n            assert!(isEven(2));\n            assert!(!isEven(3));\n        }\n\n        #[test]\n        fn test_is_odd() {\n            assert!(!isOdd(2));\n            assert!(isOdd(3));\n        }\n\n        #[test]\n        fn test_is_prime() {\n            assert!(isPrime(2));\n            assert!(!isPrime(3));\n        }\n    }\n\n    ```\n\n\n    Run `cargo test` to run the unit tests. Modify the test values to experiment\n    with the results.\n\n\n    ```shell\n\n    cargo test\n\n    ```\n\n\n    ![Function unit tests, cargo test output in the VS Code\n    terminal](https://about.gitlab.com/images/blogimages/learn-rust-with-ai-code-suggestions-getting-started/learn_rust_ai_gitlab_code_suggestions_function_unit_tests_terminal_run.png)\n\n\n    Create unit tests that fail, and commit and push the changes to GitLab. The\n    CI/CD pipelines will fail in this simulated breakage. The example above\n    needs a fix for the `test_is_prime` test. Commit and push the change to\n    verify that the pipeline passes again.\n\n\n    ```diff\n\n    -        assert!(!isPrime(3));\n\n    +        assert!(!isPrime(4));\n\n    ```\n\n\n    ## What is next\n\n    In an upcoming blog, we will look into advanced learning examples with\n    asynchronous operations, services and external API communication in future\n    blog posts. Until then, here are a few recommendations for practicing async.\n\n\n    ### Async learning exercises\n\n    - [`std misc`](https://doc.rust-lang.org/rust-by-example/std_misc.html)\n    provides asynchronous operations with threads, channels and file I/O\n\n    - Book: [Hands-on Rust: Effective Learning through 2D Game Development and\n    Play](https://pragprog.com/titles/hwrust/hands-on-rust/)\n\n    - Tutorial: [Are we game yet?](https://arewegameyet.rs/resources/tutorials/)\n\n    - Use case: [Web server with\n    rocket.rs](https://rocket.rs/v0.5-rc/guide/quickstart/#running-examples)\n\n\n    Here are a few more exercises and ideas for additional learning:\n\n    1) The Rust compiler might have created warnings that need to be addressed.\n    Follow the instructions from the `cargo build` commands and check the Git\n    diff.\n\n\n    ```shell\n\n    cargo fix --bin \"learn-rust-ai\"\n\n\n    git diff\n\n    ```\n\n\n    2) [Error handling](https://doc.rust-lang.org/rust-by-example/error.html) is\n    required when failure is detected, and the caller should know. Some errors\n    can be recovered from within the application, others require program\n    termination.\n\n\n    3) The [`std` library](https://doc.rust-lang.org/rust-by-example/std.html)\n    extends primitive types and makes programming more efficient.\n\n\n    ### Share your feedback\n\n    Which programming language are you learning or considering learning? Start a\n    new topic on our [community](/community/) forum or Discord and share your\n    experience.\n\n\n    If you are using Code Suggestions Beta with [GitLab Duo](/gitlab-duo-agent-platform/)\n    already, please share your thoughts and feedback [in this\n    issue](https://gitlab.com/gitlab-org/gitlab/-/issues/405152).\n  category: ai-ml\n  tags:\n    - DevSecOps\n    - careers\n    - tutorial\n    - workflow\n    - AI/ML\nconfig:\n  slug: learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started\n  featured: false\n  template: BlogPost\n",{"title":5,"description":17,"ogTitle":5,"ogDescription":17,"noIndex":14,"ogImage":19,"ogUrl":34,"ogSiteName":35,"ogType":36,"canonicalUrls":34},"https://about.gitlab.com/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started","https://about.gitlab.com","article","en-us/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started",[39,23,24,25,40],"devsecops","aiml",[22,23,24,25,26],"SvDzj8f9UbHCsyC5oQtt3VymjWu5GTTvjWbYPdOp3Lk",{"data":44},{"logo":45,"freeTrial":50,"sales":55,"login":60,"items":65,"search":374,"minimal":405,"duo":424,"switchNav":433,"pricingDeployment":444},{"config":46},{"href":47,"dataGaName":48,"dataGaLocation":49},"/","gitlab logo","header",{"text":51,"config":52},"Get free trial",{"href":53,"dataGaName":54,"dataGaLocation":49},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com&glm_content=default-saas-trial/","free trial",{"text":56,"config":57},"Talk to sales",{"href":58,"dataGaName":59,"dataGaLocation":49},"/sales/","sales",{"text":61,"config":62},"Sign in",{"href":63,"dataGaName":64,"dataGaLocation":49},"https://gitlab.com/users/sign_in/","sign in",[66,93,188,193,295,355],{"text":67,"config":68,"cards":70},"Platform",{"dataNavLevelOne":69},"platform",[71,77,85],{"title":67,"description":72,"link":73},"The intelligent orchestration platform for DevSecOps",{"text":74,"config":75},"Explore our Platform",{"href":76,"dataGaName":69,"dataGaLocation":49},"/platform/",{"title":78,"description":79,"link":80},"GitLab Duo Agent Platform","Agentic AI for the entire software lifecycle",{"text":81,"config":82},"Meet GitLab Duo",{"href":83,"dataGaName":84,"dataGaLocation":49},"/gitlab-duo-agent-platform/","gitlab duo agent platform",{"title":86,"description":87,"link":88},"Why GitLab","See the top reasons enterprises choose GitLab",{"text":89,"config":90},"Learn more",{"href":91,"dataGaName":92,"dataGaLocation":49},"/why-gitlab/","why gitlab",{"text":94,"left":30,"config":95,"link":97,"lists":101,"footer":170},"Product",{"dataNavLevelOne":96},"solutions",{"text":98,"config":99},"View all Solutions",{"href":100,"dataGaName":96,"dataGaLocation":49},"/solutions/",[102,126,149],{"title":103,"description":104,"link":105,"items":110},"Automation","CI/CD and automation to accelerate deployment",{"config":106},{"icon":107,"href":108,"dataGaName":109,"dataGaLocation":49},"AutomatedCodeAlt","/solutions/delivery-automation/","automated software delivery",[111,115,118,122],{"text":112,"config":113},"CI/CD",{"href":114,"dataGaLocation":49,"dataGaName":112},"/solutions/continuous-integration/",{"text":78,"config":116},{"href":83,"dataGaLocation":49,"dataGaName":117},"gitlab duo agent platform - product menu",{"text":119,"config":120},"Source Code Management",{"href":121,"dataGaLocation":49,"dataGaName":119},"/solutions/source-code-management/",{"text":123,"config":124},"Automated Software Delivery",{"href":108,"dataGaLocation":49,"dataGaName":125},"Automated software delivery",{"title":127,"description":128,"link":129,"items":134},"Security","Deliver code faster without compromising security",{"config":130},{"href":131,"dataGaName":132,"dataGaLocation":49,"icon":133},"/solutions/application-security-testing/","security and compliance","ShieldCheckLight",[135,139,144],{"text":136,"config":137},"Application Security Testing",{"href":131,"dataGaName":138,"dataGaLocation":49},"Application security testing",{"text":140,"config":141},"Software Supply Chain Security",{"href":142,"dataGaLocation":49,"dataGaName":143},"/solutions/supply-chain/","Software supply chain security",{"text":145,"config":146},"Software Compliance",{"href":147,"dataGaName":148,"dataGaLocation":49},"/solutions/software-compliance/","software compliance",{"title":150,"link":151,"items":156},"Measurement",{"config":152},{"icon":153,"href":154,"dataGaName":155,"dataGaLocation":49},"DigitalTransformation","/solutions/visibility-measurement/","visibility and measurement",[157,161,165],{"text":158,"config":159},"Visibility & Measurement",{"href":154,"dataGaLocation":49,"dataGaName":160},"Visibility and Measurement",{"text":162,"config":163},"Value Stream Management",{"href":164,"dataGaLocation":49,"dataGaName":162},"/solutions/value-stream-management/",{"text":166,"config":167},"Analytics & Insights",{"href":168,"dataGaLocation":49,"dataGaName":169},"/solutions/analytics-and-insights/","Analytics and insights",{"title":171,"items":172},"GitLab for",[173,178,183],{"text":174,"config":175},"Enterprise",{"href":176,"dataGaLocation":49,"dataGaName":177},"/enterprise/","enterprise",{"text":179,"config":180},"Small Business",{"href":181,"dataGaLocation":49,"dataGaName":182},"/small-business/","small business",{"text":184,"config":185},"Public Sector",{"href":186,"dataGaLocation":49,"dataGaName":187},"/solutions/public-sector/","public sector",{"text":189,"config":190},"Pricing",{"href":191,"dataGaName":192,"dataGaLocation":49,"dataNavLevelOne":192},"/pricing/","pricing",{"text":194,"config":195,"link":197,"lists":201,"feature":286},"Resources",{"dataNavLevelOne":196},"resources",{"text":198,"config":199},"View all resources",{"href":200,"dataGaName":196,"dataGaLocation":49},"/resources/",[202,235,258],{"title":203,"items":204},"Getting started",[205,210,215,220,225,230],{"text":206,"config":207},"Install",{"href":208,"dataGaName":209,"dataGaLocation":49},"/install/","install",{"text":211,"config":212},"Quick start guides",{"href":213,"dataGaName":214,"dataGaLocation":49},"/get-started/","quick setup checklists",{"text":216,"config":217},"Learn",{"href":218,"dataGaLocation":49,"dataGaName":219},"https://university.gitlab.com/","learn",{"text":221,"config":222},"Product documentation",{"href":223,"dataGaName":224,"dataGaLocation":49},"https://docs.gitlab.com/","product documentation",{"text":226,"config":227},"Best practice videos",{"href":228,"dataGaName":229,"dataGaLocation":49},"/getting-started-videos/","best practice videos",{"text":231,"config":232},"Integrations",{"href":233,"dataGaName":234,"dataGaLocation":49},"/integrations/","integrations",{"title":236,"items":237},"Discover",[238,243,248,253],{"text":239,"config":240},"Customer success stories",{"href":241,"dataGaName":242,"dataGaLocation":49},"/customers/","customer success stories",{"text":244,"config":245},"Blog",{"href":246,"dataGaName":247,"dataGaLocation":49},"/blog/","blog",{"text":249,"config":250},"The Source",{"href":251,"dataGaName":252,"dataGaLocation":49},"/the-source/","the source",{"text":254,"config":255},"Remote",{"href":256,"dataGaName":257,"dataGaLocation":49},"https://handbook.gitlab.com/handbook/company/culture/all-remote/","remote",{"title":259,"items":260},"Connect",[261,266,271,276,281],{"text":262,"config":263},"GitLab Services",{"href":264,"dataGaName":265,"dataGaLocation":49},"/services/","services",{"text":267,"config":268},"Community",{"href":269,"dataGaName":270,"dataGaLocation":49},"/community/","community",{"text":272,"config":273},"Forum",{"href":274,"dataGaName":275,"dataGaLocation":49},"https://forum.gitlab.com/","forum",{"text":277,"config":278},"Events",{"href":279,"dataGaName":280,"dataGaLocation":49},"/events/","events",{"text":282,"config":283},"Partners",{"href":284,"dataGaName":285,"dataGaLocation":49},"/partners/","partners",{"textColor":287,"title":288,"text":289,"link":290},"#000","What’s new in GitLab","Stay updated with our latest features and improvements.",{"text":291,"config":292},"Read the latest",{"href":293,"dataGaName":294,"dataGaLocation":49},"/releases/whats-new/","whats new",{"text":296,"config":297,"lists":299},"Company",{"dataNavLevelOne":298},"company",[300],{"items":301},[302,307,313,315,320,325,330,335,340,345,350],{"text":303,"config":304},"About",{"href":305,"dataGaName":306,"dataGaLocation":49},"/company/","about",{"text":308,"config":309,"footerGa":312},"Jobs",{"href":310,"dataGaName":311,"dataGaLocation":49},"/jobs/","jobs",{"dataGaName":311},{"text":277,"config":314},{"href":279,"dataGaName":280,"dataGaLocation":49},{"text":316,"config":317},"Leadership",{"href":318,"dataGaName":319,"dataGaLocation":49},"/company/team/e-group/","leadership",{"text":321,"config":322},"Team",{"href":323,"dataGaName":324,"dataGaLocation":49},"/company/team/","team",{"text":326,"config":327},"Handbook",{"href":328,"dataGaName":329,"dataGaLocation":49},"https://handbook.gitlab.com/","handbook",{"text":331,"config":332},"Investor relations",{"href":333,"dataGaName":334,"dataGaLocation":49},"https://ir.gitlab.com/","investor relations",{"text":336,"config":337},"Trust Center",{"href":338,"dataGaName":339,"dataGaLocation":49},"/security/","trust center",{"text":341,"config":342},"AI Transparency Center",{"href":343,"dataGaName":344,"dataGaLocation":49},"/ai-transparency-center/","ai transparency center",{"text":346,"config":347},"Newsletter",{"href":348,"dataGaName":349,"dataGaLocation":49},"/company/contact/#contact-forms","newsletter",{"text":351,"config":352},"Press",{"href":353,"dataGaName":354,"dataGaLocation":49},"/press/","press",{"text":356,"config":357,"lists":358},"Contact us",{"dataNavLevelOne":298},[359],{"items":360},[361,364,369],{"text":56,"config":362},{"href":58,"dataGaName":363,"dataGaLocation":49},"talk to sales",{"text":365,"config":366},"Support portal",{"href":367,"dataGaName":368,"dataGaLocation":49},"https://support.gitlab.com","support portal",{"text":370,"config":371},"Customer portal",{"href":372,"dataGaName":373,"dataGaLocation":49},"https://customers.gitlab.com/customers/sign_in/","customer portal",{"close":375,"login":376,"suggestions":383},"Close",{"text":377,"link":378},"To search repositories and projects, login to",{"text":379,"config":380},"gitlab.com",{"href":63,"dataGaName":381,"dataGaLocation":382},"search login","search",{"text":384,"default":385},"Suggestions",[386,388,392,394,398,402],{"text":78,"config":387},{"href":83,"dataGaName":78,"dataGaLocation":382},{"text":389,"config":390},"Code Suggestions (AI)",{"href":391,"dataGaName":389,"dataGaLocation":382},"/solutions/code-suggestions/",{"text":112,"config":393},{"href":114,"dataGaName":112,"dataGaLocation":382},{"text":395,"config":396},"GitLab on AWS",{"href":397,"dataGaName":395,"dataGaLocation":382},"/partners/technology-partners/aws/",{"text":399,"config":400},"GitLab on Google Cloud",{"href":401,"dataGaName":399,"dataGaLocation":382},"/partners/technology-partners/google-cloud-platform/",{"text":403,"config":404},"Why GitLab?",{"href":91,"dataGaName":403,"dataGaLocation":382},{"freeTrial":406,"mobileIcon":411,"desktopIcon":416,"secondaryButton":419},{"text":407,"config":408},"Start free trial",{"href":409,"dataGaName":54,"dataGaLocation":410},"https://gitlab.com/-/trials/new/","nav",{"altText":412,"config":413},"Gitlab Icon",{"src":414,"dataGaName":415,"dataGaLocation":410},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203874/jypbw1jx72aexsoohd7x.svg","gitlab icon",{"altText":412,"config":417},{"src":418,"dataGaName":415,"dataGaLocation":410},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203875/gs4c8p8opsgvflgkswz9.svg",{"text":420,"config":421},"Get Started",{"href":422,"dataGaName":423,"dataGaLocation":410},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/get-started/","get started",{"freeTrial":425,"mobileIcon":429,"desktopIcon":431},{"text":426,"config":427},"Learn more about GitLab Duo",{"href":83,"dataGaName":428,"dataGaLocation":410},"gitlab duo",{"altText":412,"config":430},{"src":414,"dataGaName":415,"dataGaLocation":410},{"altText":412,"config":432},{"src":418,"dataGaName":415,"dataGaLocation":410},{"button":434,"mobileIcon":439,"desktopIcon":441},{"text":435,"config":436},"/switch",{"href":437,"dataGaName":438,"dataGaLocation":410},"#contact","switch",{"altText":412,"config":440},{"src":414,"dataGaName":415,"dataGaLocation":410},{"altText":412,"config":442},{"src":443,"dataGaName":415,"dataGaLocation":410},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1773335277/ohhpiuoxoldryzrnhfrh.png",{"freeTrial":445,"mobileIcon":450,"desktopIcon":452},{"text":446,"config":447},"Back to pricing",{"href":191,"dataGaName":448,"dataGaLocation":410,"icon":449},"back to pricing","GoBack",{"altText":412,"config":451},{"src":414,"dataGaName":415,"dataGaLocation":410},{"altText":412,"config":453},{"src":418,"dataGaName":415,"dataGaLocation":410},{"title":455,"button":456,"config":461},"See how agentic AI transforms software delivery",{"text":457,"config":458},"Watch GitLab Transcend now",{"href":459,"dataGaName":460,"dataGaLocation":49},"/events/transcend/virtual/","transcend event",{"layout":462,"icon":463,"disabled":30},"release","AiStar",{"data":465},{"text":466,"source":467,"edit":473,"contribute":478,"config":483,"items":488,"minimal":693},"Git is a trademark of Software Freedom Conservancy and our use of 'GitLab' is under license",{"text":468,"config":469},"View page source",{"href":470,"dataGaName":471,"dataGaLocation":472},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/","page source","footer",{"text":474,"config":475},"Edit this page",{"href":476,"dataGaName":477,"dataGaLocation":472},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/content/","web ide",{"text":479,"config":480},"Please contribute",{"href":481,"dataGaName":482,"dataGaLocation":472},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/CONTRIBUTING.md/","please contribute",{"twitter":484,"facebook":485,"youtube":486,"linkedin":487},"https://twitter.com/gitlab","https://www.facebook.com/gitlab","https://www.youtube.com/channel/UCnMGQ8QHMAnVIsI3xJrihhg","https://www.linkedin.com/company/gitlab-com",[489,536,588,632,659],{"title":189,"links":490,"subMenu":505},[491,495,500],{"text":492,"config":493},"View plans",{"href":191,"dataGaName":494,"dataGaLocation":472},"view plans",{"text":496,"config":497},"Why Premium?",{"href":498,"dataGaName":499,"dataGaLocation":472},"/pricing/premium/","why premium",{"text":501,"config":502},"Why Ultimate?",{"href":503,"dataGaName":504,"dataGaLocation":472},"/pricing/ultimate/","why ultimate",[506],{"title":507,"links":508},"Contact Us",[509,512,514,516,521,526,531],{"text":510,"config":511},"Contact sales",{"href":58,"dataGaName":59,"dataGaLocation":472},{"text":365,"config":513},{"href":367,"dataGaName":368,"dataGaLocation":472},{"text":370,"config":515},{"href":372,"dataGaName":373,"dataGaLocation":472},{"text":517,"config":518},"Status",{"href":519,"dataGaName":520,"dataGaLocation":472},"https://status.gitlab.com/","status",{"text":522,"config":523},"Terms of use",{"href":524,"dataGaName":525,"dataGaLocation":472},"/terms/","terms of use",{"text":527,"config":528},"Privacy statement",{"href":529,"dataGaName":530,"dataGaLocation":472},"/privacy/","privacy statement",{"text":532,"config":533},"Cookie preferences",{"dataGaName":534,"dataGaLocation":472,"id":535,"isOneTrustButton":30},"cookie preferences","ot-sdk-btn",{"title":94,"links":537,"subMenu":546},[538,542],{"text":539,"config":540},"DevSecOps platform",{"href":76,"dataGaName":541,"dataGaLocation":472},"devsecops platform",{"text":543,"config":544},"AI-Assisted Development",{"href":83,"dataGaName":545,"dataGaLocation":472},"ai-assisted development",[547],{"title":548,"links":549},"Topics",[550,555,560,565,570,573,578,583],{"text":551,"config":552},"CICD",{"href":553,"dataGaName":554,"dataGaLocation":472},"/topics/ci-cd/","cicd",{"text":556,"config":557},"GitOps",{"href":558,"dataGaName":559,"dataGaLocation":472},"/topics/gitops/","gitops",{"text":561,"config":562},"DevOps",{"href":563,"dataGaName":564,"dataGaLocation":472},"/topics/devops/","devops",{"text":566,"config":567},"Version Control",{"href":568,"dataGaName":569,"dataGaLocation":472},"/topics/version-control/","version control",{"text":22,"config":571},{"href":572,"dataGaName":39,"dataGaLocation":472},"/topics/devsecops/",{"text":574,"config":575},"Cloud Native",{"href":576,"dataGaName":577,"dataGaLocation":472},"/topics/cloud-native/","cloud native",{"text":579,"config":580},"AI for Coding",{"href":581,"dataGaName":582,"dataGaLocation":472},"/topics/devops/ai-for-coding/","ai for coding",{"text":584,"config":585},"Agentic AI",{"href":586,"dataGaName":587,"dataGaLocation":472},"/topics/agentic-ai/","agentic ai",{"title":589,"links":590},"Solutions",[591,593,595,600,604,607,611,614,616,619,622,627],{"text":136,"config":592},{"href":131,"dataGaName":136,"dataGaLocation":472},{"text":125,"config":594},{"href":108,"dataGaName":109,"dataGaLocation":472},{"text":596,"config":597},"Agile development",{"href":598,"dataGaName":599,"dataGaLocation":472},"/solutions/agile-delivery/","agile delivery",{"text":601,"config":602},"SCM",{"href":121,"dataGaName":603,"dataGaLocation":472},"source code management",{"text":551,"config":605},{"href":114,"dataGaName":606,"dataGaLocation":472},"continuous integration & delivery",{"text":608,"config":609},"Value stream management",{"href":164,"dataGaName":610,"dataGaLocation":472},"value stream management",{"text":556,"config":612},{"href":613,"dataGaName":559,"dataGaLocation":472},"/solutions/gitops/",{"text":174,"config":615},{"href":176,"dataGaName":177,"dataGaLocation":472},{"text":617,"config":618},"Small business",{"href":181,"dataGaName":182,"dataGaLocation":472},{"text":620,"config":621},"Public sector",{"href":186,"dataGaName":187,"dataGaLocation":472},{"text":623,"config":624},"Education",{"href":625,"dataGaName":626,"dataGaLocation":472},"/solutions/education/","education",{"text":628,"config":629},"Financial services",{"href":630,"dataGaName":631,"dataGaLocation":472},"/solutions/finance/","financial services",{"title":194,"links":633},[634,636,638,640,643,645,647,649,651,653,655,657],{"text":206,"config":635},{"href":208,"dataGaName":209,"dataGaLocation":472},{"text":211,"config":637},{"href":213,"dataGaName":214,"dataGaLocation":472},{"text":216,"config":639},{"href":218,"dataGaName":219,"dataGaLocation":472},{"text":221,"config":641},{"href":223,"dataGaName":642,"dataGaLocation":472},"docs",{"text":244,"config":644},{"href":246,"dataGaName":247,"dataGaLocation":472},{"text":239,"config":646},{"href":241,"dataGaName":242,"dataGaLocation":472},{"text":254,"config":648},{"href":256,"dataGaName":257,"dataGaLocation":472},{"text":262,"config":650},{"href":264,"dataGaName":265,"dataGaLocation":472},{"text":267,"config":652},{"href":269,"dataGaName":270,"dataGaLocation":472},{"text":272,"config":654},{"href":274,"dataGaName":275,"dataGaLocation":472},{"text":277,"config":656},{"href":279,"dataGaName":280,"dataGaLocation":472},{"text":282,"config":658},{"href":284,"dataGaName":285,"dataGaLocation":472},{"title":296,"links":660},[661,663,665,667,669,671,673,677,682,684,686,688],{"text":303,"config":662},{"href":305,"dataGaName":298,"dataGaLocation":472},{"text":308,"config":664},{"href":310,"dataGaName":311,"dataGaLocation":472},{"text":316,"config":666},{"href":318,"dataGaName":319,"dataGaLocation":472},{"text":321,"config":668},{"href":323,"dataGaName":324,"dataGaLocation":472},{"text":326,"config":670},{"href":328,"dataGaName":329,"dataGaLocation":472},{"text":331,"config":672},{"href":333,"dataGaName":334,"dataGaLocation":472},{"text":674,"config":675},"Sustainability",{"href":676,"dataGaName":674,"dataGaLocation":472},"/sustainability/",{"text":678,"config":679},"Diversity, inclusion and belonging (DIB)",{"href":680,"dataGaName":681,"dataGaLocation":472},"/diversity-inclusion-belonging/","Diversity, inclusion and belonging",{"text":336,"config":683},{"href":338,"dataGaName":339,"dataGaLocation":472},{"text":346,"config":685},{"href":348,"dataGaName":349,"dataGaLocation":472},{"text":351,"config":687},{"href":353,"dataGaName":354,"dataGaLocation":472},{"text":689,"config":690},"Modern Slavery Transparency Statement",{"href":691,"dataGaName":692,"dataGaLocation":472},"https://handbook.gitlab.com/handbook/legal/modern-slavery-act-transparency-statement/","modern slavery transparency statement",{"items":694},[695,698,701],{"text":696,"config":697},"Terms",{"href":524,"dataGaName":525,"dataGaLocation":472},{"text":699,"config":700},"Cookies",{"dataGaName":534,"dataGaLocation":472,"id":535,"isOneTrustButton":30},{"text":702,"config":703},"Privacy",{"href":529,"dataGaName":530,"dataGaLocation":472},[705],{"id":706,"title":9,"body":28,"config":707,"content":709,"description":28,"extension":27,"meta":713,"navigation":30,"path":714,"seo":715,"stem":716,"__hash__":717},"blogAuthors/en-us/blog/authors/michael-friedrich.yml",{"template":708},"BlogAuthor",{"name":9,"config":710},{"headshot":711,"ctfId":712},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749659879/Blog/Author%20Headshots/dnsmichi-headshot.jpg","dnsmichi",{},"/en-us/blog/authors/michael-friedrich",{},"en-us/blog/authors/michael-friedrich","lJ-nfRIhdG49Arfrxdn1Vv4UppwD51BB13S3HwIswt4",[719,732,744],{"content":720,"config":730},{"title":721,"description":722,"authors":723,"heroImage":725,"date":726,"body":727,"category":11,"tags":728},"GitLab and Anthropic: Governed AI for enterprise development","GitLab deepens its Anthropic Claude integration, bringing governed AI, access to new models, and cloud flexibility to enterprise software development.",[724],"Stuart Moncada","https://res.cloudinary.com/about-gitlab-com/image/upload/v1776457632/llddiylsgwuze0u1rjks.png","2026-04-28","For enterprise and public sector leaders, the tension is familiar: Software teams need to move faster with AI, while security, compliance, and regulatory expectations only get more stringent. GitLab deepens its Anthropic Claude integration so organizations get access to newly released Claude models inside GitLab’s intelligent orchestration platform where governance, compliance, and auditability already run.\n\nClaude powers capabilities across GitLab Duo Agent Platform as the default model out of the box, across a variety of use cases from code generation and review to agentic chat and vulnerability resolution. If you've used GitLab Duo, you've already experienced how Duo agents automate workflows across the entire software development lifecycle (SDLC).\n\nThis accelerates the integration of Claude’s capabilities into GitLab, broadens how enterprises can deploy them, and reinforces what makes GitLab fundamentally different as a platform for software development and engineering: governance, compliance, and auditability built into every AI interaction.\n\n> \"GitLab Duo has accelerated how our teams plan, build, and ship software. The combination of Anthropic's Claude and GitLab's platform means we're getting more capable AI without changing how we work or how it is governed.\"\n>\n> – Mans Booijink, Operations Manager, Cube\n\n## The real differentiator: Governed AI\n\nWith GitLab, governance controls and auditing are built into the SDLC. When Claude suggests a code change through the GitLab Duo Agent Platform, that suggestion flows through the same merge request process, the same approval rules, the same security scanning, and the same audit trail as every other change. AI doesn't get a shortcut around your controls. It operates within them.\n\nAs GitLab moves deeper into agentic software development, where AI autonomously handles well-defined tasks, the governance layer becomes more important. An AI agent that can open a merge request, help resolve a vulnerability, or refactor a service needs to be auditable, attributable, and subject to the same policy enforcement as a human developer. That requirement is an architectural decision GitLab made from the start, and one that grows more consequential as AI agents take on broader responsibilities.\n\n## Enterprise deployment flexibility\n\nThis also expands how organizations access the latest Claude models through GitLab. Claude is available within GitLab through Google Cloud's Vertex AI and Amazon Bedrock, which means enterprises can route AI workloads through the hyperscaler commitments and cloud governance frameworks they already have in place. No separate vendor contract. No new data residency questions. Your existing Google Cloud or AWS relationship is the on-ramp. \n\nGitLab is now also available in the [Claude Marketplace](https://claude.com/platform/marketplace), allowing customers to purchase GitLab Credits and apply them toward existing Anthropic spending commitments – consolidating AI spend and simplifying how teams discover and procure GitLab alongside their Anthropic investments.\n\n## Advancing an agentic future\n\nGitLab's vision for agentic software development, where AI handles defined tasks autonomously across planning, coding, testing, securing, and deploying, requires models with strong reasoning, reliability, and safety characteristics. It also requires a platform where those autonomous actions are fully governed.\n\nAgentic workflows demand models with strong reasoning, reliability, and safety characteristics, criteria that guide how GitLab selects and integrates AI model partners. And GitLab's governance framework helps ensure that as AI agents assume more advanced development work, enterprises maintain full visibility and control over what those agents do, when they do it, and how changes are tracked.\n\n## What this means for GitLab customers\n\nIf you're already using GitLab Duo Agent Platform, you'll get access to Claude models and deeper AI assistance across your software development lifecycle, all within the governance framework you already rely on.\n\nIf you're evaluating AI-powered software development platforms, you shouldn't have to choose between advanced AI capabilities and enterprise control. This strategic integration is built to deliver both.\n\n> Want to learn more about GitLab Duo Agent Platform? [Get a demo or start a free trial today](https://about.gitlab.com/gitlab-duo-agent-platform/).",[26,729,285],"product",{"featured":30,"template":15,"slug":731},"gitlab-and-anthropic-governed-ai-for-enterprise-development",{"content":733,"config":742},{"title":734,"description":735,"authors":736,"heroImage":738,"date":739,"body":740,"category":11,"tags":741},"Give your AI agent direct, structured GitLab access with glab CLI","The GitLab CLI (glab) provides AI agents structured, reliable access to projects via the MCP, eliminating friction. This tutorial shows how you can speed up code review and issue triage.",[737],"Kai Armstrong","https://res.cloudinary.com/about-gitlab-com/image/upload/v1776347152/unw3mzatkd5xyfbzcnni.png","2026-04-27","\nWhen teams use GitLab Duo, Claude, Cursor, and other AI assistants, more of the development workflow runs through an AI agent acting on your behalf — reading issues, reviewing merge requests, running pipelines, and helping you ship faster. Most developers are already using the GitLab CLI (`glab`) from the terminal to interact with GitLab. Combining the two is a natural next step.\n\n\nThe problem is that without the right tools, AI agents are essentially guessing when it comes to your GitLab projects. They might hallucinate the details of an issue they've never seen, summarize a merge request based on stale training data rather than its actual state, or require you to manually copy context from a browser tab and paste it into a chat window just to get started. Every one of those workarounds is friction: it slows you down, introduces the possibility of error, and puts a hard ceiling on what your agent can actually do on your behalf. `glab` changes that by giving agents a direct, reliable interface to your projects.\n\n\nWith `glab`, your agent fetches what it needs directly from GitLab, acts on it, and reports back — so you spend less time relaying information and more time on the work that matters.\n\n\nIn this tutorial, you'll learn how to use `glab` to give AI agents structured, reliable access to your GitLab projects. You'll also discover how that unlocks a faster, more capable development workflow.\n\n\n## How to connect your AI agent to GitLab through MCP\n\n\nThe most direct way to supercharge your AI workflow is to give your AI agent native access to `glab` through Model Context Protocol ([MCP](https://about.gitlab.com/topics/ai/model-context-protocol/)).\n\n\n MCP is an open standard that lets AI tools discover and use external capabilities at runtime. Once connected, your AI assistant can read issues, comment on merge requests, check pipeline status, and write back to GitLab, all without copying anything from the UI or writing a single API call yourself.\n\n\n To get started, run:\n\n\n ```shell\n # Start the glab MCP server\n glab mcp serve\n ```\n\n\n Once your MCP client is configured, your AI can answer questions like *\"What's the status of my open MRs?\"* or *\"Are there any failing pipelines on main?\"* by querying GitLab directly, not scraping the web UI, not relying on stale training data. See the [full setup docs](https://docs.gitlab.com/cli/) for configuration steps for Claude Code, Cursor, and other editors.\n\n\n One detail worth knowing: `glab` automatically adds `--output json` when invoked through MCP, for any command that supports it. Your agent gets clean, structured data without you needing to think about output formats. And because `glab` uses the official MCP SDK, it stays compatible as the\n protocol evolves.\n\n\n We've also been deliberate about *which* commands are exposed through MCP. Commands that require interactive terminal input are intentionally\n excluded, so your agent never gets stuck waiting for input that will never come. What's exposed is what actually works reliably in an agent context.\n\n\n ## Let your AI participate in code review\n\n\n Most developers have a backlog of MRs waiting for review. It's one of the most time-consuming parts of the job and one of the best places to put\n AI to work. With `glab`, your agent doesn't just observe your review queue, it can work through it with you.\n\n\n ### See exactly what still needs addressing\n\n\n Start with this:\n\n\n ```shell\n glab mr view 2677 --comments --unresolved --output json\n ```\n\n\n This input returns the full MR: metadata, description, and every\n unresolved discussion, as a single structured JSON payload. Hand that to\n your AI and it has everything it needs: which threads are open, what the\n reviewer asked for, and in what context. No tab-switching, no copy-pasting\n individual comments.\n\n\n \n ```json\n {\n   \"id\": 2677,\n   \"title\": \"feat: add OAuth2 support\",\n   \"state\": \"opened\",\n   \"author\": { \"username\": \"jdwick\" },\n   \"labels\": [\"backend\", \"needs-review\"],\n   \"blocking_discussions_resolved\": false,\n   \"discussions\": [\n     {\n       \"id\": \"3107030349\",\n       \"resolved\": false,\n       \"notes\": [\n         {\n           \"author\": { \"username\": \"dmurphy\" },\n           \"body\": \"This error handling will swallow panics — consider wrapping with recover()\",\n           \"created_at\": \"2026-03-14T09:23:11.000Z\"\n         }\n       ]\n     },\n     {\n       \"id\": \"3107030412\",\n       \"resolved\": false,\n       \"notes\": [\n         {\n           \"author\": { \"username\": \"sreeves\" },\n           \"body\": \"Token refresh logic needs a test for the expired token case\",\n           \"created_at\": \"2026-03-14T10:05:44.000Z\"\n         }\n       ]\n     }\n   ]\n }\n ```\n\n\n Instead of reading through every thread yourself, you ask your agent  *\"what do I still need to fix in MR 2677?\"* and get back a prioritized summary with suggested changes. This all happens from a single command.\n\n\n ### Close the loop programmatically\n\n\n Once your AI has helped you address the feedback, it can resolve\n discussions:\n\n\n ```shell\n # List all discussions — structured, ready for the agent to process\n glab mr note list 456 --output json\n\n # Resolve a discussion once the feedback is addressed\n glab mr note resolve 456 3107030349\n\n # Reopen if something needs another look\n glab mr note reopen 456 3107030349\n ```\n\n\n\n ```json\n [\n   {\n     \"id\": 3107030349,\n     \"body\": \"This error handling will swallow panics — consider wrapping with recover()\",\n     \"author\": { \"username\": \"dmurphy\" },\n     \"resolved\": false,\n     \"resolvable\": true\n   },\n   {\n     \"id\": 3107030412,\n     \"body\": \"Token refresh logic needs a test for the expired token case\",\n     \"author\": { \"username\": \"sreeves\" },\n     \"resolved\": false,\n     \"resolvable\": true\n   }\n ]\n ```\n\n\n\n Note IDs are visible directly in the GitLab UI and API, no extra lookup needed. Your agent can work through the full list, verify each fix, and\n resolve as it goes.\n\n\n ## Talk to your AI about your code more effectively\n\n\n Even if you're not running an MCP server, there's a simpler shift that makes a huge difference: using `glab` to feed your AI better information.\n\n\n Think about the last time you asked an AI assistant to help triage issues or debug a failing pipeline. You probably copied some text from the GitLab UI and pasted it into the chat. Here's what your agent is actually\n working with when you do that:\n\n\n ```text\n open issues: 12 • milestone: 17.10 • label: bug, needs-triage ...\n ```\n\n\n Compare that to what it gets with `glab`:\n\n\n \n ```json\n [\n   {\n     \"iid\": 902,\n     \"title\": \"Pipeline fails on merge to main\",\n     \"labels\": [\"bug\", \"needs-triage\"],\n     \"milestone\": { \"title\": \"17.10\" },\n     \"assignees\": []\n   },\n   ...\n ]\n ```\n\n\n Structured, typed, complete; no ambiguity, no parsing guesswork. That's the difference between an agent that can act and one that has to ask\n follow-up questions.\n\n\n If you're using the MCP server, you get this automatically: `glab` adds `--output json` for any command that supports it. If you're working directly\n from the terminal, just add the flag yourself:\n\n\n ```shell\n # Pull open issues for triage\n glab issue list --label \"needs-triage\" --output json\n\n # Check pipeline status\n glab ci status --output json\n\n # Get full MR details\n glab mr view 456 --output json\n ```\n\n\n We've significantly expanded JSON output support in recent releases. It now covers CI status, milestones, labels, releases, schedules, cluster agents, work items, MR approvers, repo contributors, and more. If `glab` can\n retrieve it, your AI can consume it cleanly.\n\n\n ### A real workflow\n\n\n ```shell\n $ glab issue list --label \"needs-triage\" --milestone \"17.10\"\n --output json\n ```\n\n\n ```text\n Agent: I found 2 unassigned bugs in the 17.10 milestone that need triage:\n 1. #902 — Pipeline fails on merge to main (opened 5 days ago)\n 2. #903 — Auth token not refreshing on expiry (opened 4 days ago)\n Both are unassigned. Want me to draft triage notes and suggest assignees based on recent commit history?\n ```\n\n\n ## Your agent is never limited to built-in commands\n\n\n `glab`'s first-class commands cover the most common workflows, but your agent is never limited to them. Through `glab api`, it has authenticated access to the full GitLab REST and GraphQL API surface, using the same session, with no extra credentials or configuration required.\n\n\n This is a meaningful differentiator. Most CLI tools stop at what their commands expose. With `glab`, if GitLab's API supports it, your agent can do it. It's always working from a trusted, authenticated context.\n\n\n A practical example: fetching just the list of changed files in an MR before deciding which diffs to pull in full:\n\n\n ```shell\n # Get changed file paths — lightweight, no diff content yet\n glab api \"/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/diffs?per_page=100\" \\\n | jq '.[].new_path'\n\n# Then fetch only the specific file your agent needs\nglab api \"/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/diffs?per_page=100\" \\\n| jq '.[] | select(.new_path == \"path/to/file.go\")'\n ```\n\n\n ```text\n \"internal/auth/token.go\"\n \"internal/auth/token_test.go\"\n \"internal/oauth/refresh.go\"\n ```\n\n\n For anything the REST API doesn't cover (epics, certain work item queries, complex cross-project data),  `glab api graphql` gives you the full\n GraphQL interface:\n\n\n ```shell\n   glab api graphql -f query='\n {\n   project(fullPath: \"gitlab-org/gitlab\") {\n     mergeRequest(iid: \"12345\") {\n       title\n       reviewers { nodes { username } }\n     }\n   }\n }'\n ```\n\n ```json\n{\n   \"data\": {\n     \"project\": {\n       \"mergeRequest\": {\n         \"title\": \"feat: add OAuth2 support\",\n         \"reviewers\": {\n           \"nodes\": [\n             { \"username\": \"dmurphy\" },\n             { \"username\": \"sreeves\" }\n           ]\n         }\n       }\n     }\n   }\n }\n\n ```\n\n\n Your agent has a single, authenticated entry point to everything GitLab exposes without the token juggling, separate API clients, or configuration\n overhead.\n\n\n ## What's coming and your feedback\n\n\n Two improvements we're actively working on will make `glab` even more useful for agent workflows:\n\n\n **Agent-aware help text.** Today, `--help` output is written for humansvat a terminal. We're updating it to surface the non-interactive alternative\n for every interactive command, flag which commands support `--output json`, and generally make help a useful resource for agents discovering\n capabilities at runtime — not just humans.\n\n\n **Better machine-readable errors.** When something goes wrong today, agents get the same human-readable error messages as terminal users. We're\n changing that so errors in JSON mode return structured output, giving your agent the information it needs to handle failures gracefully, retry intelligently, or surface the right context back to you.\n\n\n Both of these are in active development. If you're already using `glab` with an AI tool, you're exactly the audience we want feedback from.\n\n\n * **What friction are you hitting?** Commands that don't behave well in agent contexts, error messages that aren't actionable, gaps in JSON output\n coverage. We want to know.\n\n * **What workflows have you unlocked?** Real usage patterns help us prioritize what to build next.\n\n\n Join the discussion in [our feedback issue](https://gitlab.com/gitlab-org/cli/-/issues/8177) — that's where we're shaping the roadmap for agent-friendliness, and where your input will have the most direct impact. If you've found a specific gap, [open an issue](https://gitlab.com/gitlab-org/cli/-/issues/new). If you've got a fix in mind, contributions are welcome. Visit [CONTRIBUTING.md](https://gitlab.com/gitlab-org/cli/-/blob/main/CONTRIBUTING.md) to get started.\n\n\n The GitLab CLI has always been about giving developers more control over their workflow. As AI becomes a bigger part of how we all work, that means making `glab` the best possible interface between your AI tools and your GitLab projects. We're just getting started and we'd love to build the next part with you.\n",[26,729,24],{"featured":30,"template":15,"slug":743},"give-your-ai-agent-direct-structured-gitlab-access-with-glab-cli",{"content":745,"config":753},{"title":746,"description":747,"authors":748,"heroImage":738,"date":750,"body":751,"category":11,"tags":752},"GitHub Copilot's new policy for AI training is a governance wake-up call","Learn what GitHub's Copilot policy change means for regulated industries, and why GitLab's commitment to customer data privacy matters.",[749],"Allie Holland","2026-04-20","GitHub recently [announced](https://github.blog/news-insights/company-news/updates-to-github-copilot-interaction-data-usage-policy/) a significant change to how it handles data from Copilot users. Starting April 24, 2026, interaction data from Copilot Free, Pro, and Pro+ users, including inputs, outputs, code snippets, and associated context, will be used to train AI models by default, unless users actively opt out. Copilot Business and Enterprise customers are exempt under existing contract terms.\n\nFor organizations in regulated industries, including finance, healthcare, defense, and public sector, the policy shift raises questions that go beyond individual developer preferences. It forces a harder look at a question that engineering and security leaders should be asking every AI vendor in their stack: Do you train on our code? \n\nGitLab's answer is no. GitLab does not train AI models on customer code at any tier, and AI vendors are contractually prohibited from using customer inputs or outputs for their own purposes. The [GitLab AI Transparency Center](https://about.gitlab.com/ai-transparency-center/) makes that commitment auditable: a single location documenting which models power which features, how data is handled, subprocessor relationships, and data retention periods. The GitLab AI Transparency Center also lists the compliance status of each feature, including confirmation that GitLab's current AI features do not qualify as high-risk systems under the EU AI Act. It's a standard GitLab CEO Bill Staples has consistently [reiterated](https://www.linkedin.com/posts/williamstaples_gitlab-1810-agentic-ai-now-open-to-even-activity-7443280763715985408-aHxf?utm_source=share&utm_medium=member_desktop&rcm=ACoAABsu7EUBcb_a1-JHKS9RC0B5rf8Ye-5XM60) and one reflected in GitLab's mission and [Trust Center](https://trust.gitlab.com/).\n\n## What the policy change actually means\n\nGitHub's announcement also specifies that the data may be shared with GitHub affiliates, including Microsoft, for AI development purposes.\n\nA policy change of this nature forces organizations to re-examine their AI governance posture, audit their Copilot license tiers, and confirm that the right controls are configured across their teams.\n\n## Why AI governance matters in regulated environments\n\nSource code is often among an organization's most sensitive intellectual property. It may contain references to internal systems, reflect proprietary business logic, or touch data flows governed by strict retention and access policies. When that code passes through an AI assistant, questions about training data usage, model vendor relationships, and data residency become compliance concerns.\n\nThe exposure is particularly acute for financial services firms that have invested in proprietary algorithms, fraud detection logic, credit risk models, underwriting rules, trading strategies. When AI tooling processes that code and uses it to train models serving competitors, vendor data practices become an IP concern.\n\nFinancial institutions operating under [the Federal Reserve's Supervisory Guidance on Model Risk Management (SR 11-7) and the](https://www.federalreserve.gov/supervisionreg/srletters/sr1107.htm) [Digital Operational Resilience Act (DORA)](https://eur-lex.europa.eu/eli/reg/2022/2554/oj/eng) are required to maintain documented, auditable oversight of third-party technology providers, including understanding how those providers handle data. Third-party AI tools used in development workflows increasingly fall within the scope of model risk oversight, and material changes to vendor data practices require updated documentation. \n\nIn the public sector, [the National Institute of Standards and Technology Special Publication 800-53 (NIST 800-53)](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final) and the [Federal Information Security Modernization Act (FISMA)](https://www.cisa.gov/topics/cyber-threats-and-advisories/federal-information-security-modernization-act) establish that sensitive or classified code must never leave a controlled boundary. For U.S. Department of Defense and intelligence community environments in particular, a vendor's default data posture is an operational concern. In healthcare, [the Health Insurance Portability and Accountability Act (HIPAA)](https://www.hhs.gov/hipaa/index.html) governs how patient-adjacent data is handled by third parties, and development environments that touch clinical systems increasingly fall within that scope.\n\nAcross all of these contexts, the common thread is the same: A vendor policy that changes data usage defaults, requires individual opt-out, and offers different protections depending on account tier introduces exactly the kind of uncontrolled variable that compliance teams cannot afford.\n\n## What regulated industries actually need from AI vendors\n\nRegulated organizations have largely moved past debating whether to adopt AI in development workflows. The focus now is on doing so in a way they can defend to regulators, boards, and customers. That shift has surfaced a consistent set of requirements regardless of sector.\n\n**Contractual certainty.** Regulated firms need to know, with specificity, what happens to their data. A clear, documented, unconditional commitment is what's required, not something that varies by plan or requires action before a deadline.\n\n**Auditability.** Model risk management frameworks require organizations to understand and validate the AI systems they deploy, including the training data behind those models and the third parties involved in their development. Vendors who cannot answer these questions create documentation risk for the organizations relying on them.\n\n**Separation from vendor incentives.** When an AI vendor trains models on customer usage data, code and workflows become inputs to a system that also serves competitors. For institutions with proprietary trading logic, underwriting models, or fraud detection systems, that's a genuine IP exposure.\n\n## GitLab's position on AI data governance\n\nGitLab does not use customer code to train AI models. This commitment applies at every tier, and AI vendors are contractually prohibited from using inputs or outputs associated with GitLab customers for their own purposes.\n\nThis is a deliberate architectural and policy choice, not a feature of a particular pricing tier. As GitLab's [post on enterprise independence](https://about.gitlab.com/blog/why-enterprise-independence-matters-more-than-ever-in-devsecops/) notes, data governance has become \"an increasingly critical factor in enterprise technology decisions, driven by a complex web of national and regional data protection laws and growing concern about control over sensitive intellectual property.\"\n\nGitLab is also cloud-neutral and model-neutral while supporting self-hosted deployments, not commercially tied to any single cloud provider or large language model (LLM). That i[ndependence matters](https://about.gitlab.com/blog/why-enterprise-independence-matters-more-than-ever-in-devsecops/) for regulated organizations evaluating vendor concentration risk. The [AI Continuity Plan](https://handbook.gitlab.com/handbook/product/ai/continuity-plan/) documents how vendor changes are managed, including material changes to how AI vendors treat customer data, a direct response to the governance requirements under frameworks like [DORA](https://handbook.gitlab.com/handbook/legal/dora/). \n\n## The governance gap AI teams need to close\n\nGitHub's policy update is a reminder that for organizations in regulated industries, understanding exactly how an AI tool handles data is a prerequisite for using it at all. That means asking vendors for clear, documented answers: Is our data used for model training? Who are your AI model subprocessors? What happens if a vendor changes its data practices? Can we deploy in a way that keeps all AI processing within our own infrastructure? What indemnification do you offer for AI-generated output?\n\nVendors who can answer those questions clearly, and document those answers in an auditable form, are vendors you can build on. **Those who cannot will create compliance debt every time they ship a policy update.** And when a vendor can change its data practices with 30 days notice, that's not a partnership built for regulated industries. That's a liability.\n\n> Learn more about GitLab's approach to AI governance at the [GitLab AI Transparency Center](https://about.gitlab.com/ai-transparency-center/).",[26,729],{"featured":14,"template":15,"slug":754},"github-copilots-new-policy-for-ai-training-is-a-governance-wake-up-call",{"promotions":756},[757,770,781,793],{"id":758,"categories":759,"header":760,"text":761,"button":762,"image":767},"ai-modernization",[11],"Is AI achieving its promise at scale?","Quiz will take 5 minutes or less",{"text":763,"config":764},"Get your AI maturity score",{"href":765,"dataGaName":766,"dataGaLocation":247},"/assessments/ai-modernization-assessment/","modernization assessment",{"config":768},{"src":769},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/qix0m7kwnd8x2fh1zq49.png",{"id":771,"categories":772,"header":773,"text":761,"button":774,"image":778},"devops-modernization",[729,39],"Are you just managing tools or shipping innovation?",{"text":775,"config":776},"Get your DevOps maturity score",{"href":777,"dataGaName":766,"dataGaLocation":247},"/assessments/devops-modernization-assessment/",{"config":779},{"src":780},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138785/eg818fmakweyuznttgid.png",{"id":782,"categories":783,"header":785,"text":761,"button":786,"image":790},"security-modernization",[784],"security","Are you trading speed for security?",{"text":787,"config":788},"Get your security maturity score",{"href":789,"dataGaName":766,"dataGaLocation":247},"/assessments/security-modernization-assessment/",{"config":791},{"src":792},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/p4pbqd9nnjejg5ds6mdk.png",{"id":794,"paths":795,"header":798,"text":799,"button":800,"image":805},"github-azure-migration",[796,797],"migration-from-azure-devops-to-gitlab","integrating-azure-devops-scm-and-gitlab","Is your team ready for GitHub's Azure move?","GitHub is already rebuilding around Azure. Find out what it means for you.",{"text":801,"config":802},"See how GitLab compares to GitHub",{"href":803,"dataGaName":804,"dataGaLocation":247},"/compare/gitlab-vs-github/github-azure-migration/","github azure migration",{"config":806},{"src":780},{"header":808,"blurb":809,"button":810,"secondaryButton":815},"Start building faster today","See what your team can do with the intelligent orchestration platform for DevSecOps.\n",{"text":811,"config":812},"Get your free trial",{"href":813,"dataGaName":54,"dataGaLocation":814},"https://gitlab.com/-/trial_registrations/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/","feature",{"text":510,"config":816},{"href":58,"dataGaName":59,"dataGaLocation":814},1777493605992]