Repository: JanDeDobbeleer/oh-my-posh
Pull request #2886 (2022-10-05 10:19:14)

feat(rust): add beta/dev/nightly to version string
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md]
- [x] The commit message follows the [conventional commits][cc] guidelines
- [x] Tests for the changes have been added (for bug fixes/features)
- [x] Docs have been added/updated (for bug fixes/features)

### Description

<!--TemplateBody-->

<!---

Tips:

If you're not comfortable with working with Git, we're working a guide (https://ohmyposh.dev/docs/contributing_git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/segments/rust.go b/src/segments/rust.go
index 2ba9003a..98238fc4 100644
--- a/src/segments/rust.go
+++ b/src/segments/rust.go
@@ -22,7 +22,7 @@ func (r *Rust) Init(props properties.Properties, env environment.Environment) {
 			{
 				executable: "rustc",
 				args:       []string{"--version"},
-				regex:      `rustc (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
+				regex:      `rustc (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))(-(?P<prerelease>[a-z]+))?) (\((?P<buildmetadata>[0-9a-f]+ [0-9]+-[0-9]+-[0-9]+)\))`,
 			},
 		},
 	}
diff --git a/website/docs/segments/rust.mdx b/website/docs/segments/rust.mdx
index de6d9104..7b61a3d4 100644
--- a/website/docs/segments/rust.mdx
+++ b/website/docs/segments/rust.mdx
@@ -42,12 +42,13 @@ Display the currently active rust version.
 
 ### Properties
 
-| Name     | Type     | Description                                        |
-| -------- | -------- | -------------------------------------------------- |
-| `.Full`  | `string` | the full version                                   |
-| `.Major` | `string` | major number                                       |
-| `.Minor` | `string` | minor number                                       |
-| `.Patch` | `string` | patch number                                       |
-| `.Error` | `string` | error encountered when fetching the version string |
+| Name          | Type     | Description                                        |
+| ------------- | -------- | -------------------------------------------------- |
+| `.Full`       | `string` | the full version                                   |
+| `.Major`      | `string` | major number                                       |
+| `.Minor`      | `string` | minor number                                       |
+| `.Patch`      | `string` | patch number                                       |
+| `.Prerelease` | `string` | channel name                                       |
+| `.Error`      | `string` | error encountered when fetching the version string |
 
 [templates]: /docs/configuration/templates


Test patch:
diff --git a/src/segments/rust_test.go b/src/segments/rust_test.go
index 75ef4313..6cf4492d 100644
--- a/src/segments/rust_test.go
+++ b/src/segments/rust_test.go
@@ -14,6 +14,7 @@ func TestRust(t *testing.T) {
 		Version        string
 	}{
 		{Case: "Rust 1.53.0", ExpectedString: "1.53.0", Version: "rustc 1.53.0 (4369396ce 2021-04-27)"},
+		{Case: "Rust 1.66.0", ExpectedString: "1.66.0-nightly", Version: "rustc 1.66.0-nightly (01af5040f 2022-10-04)"},
 	}
 	for _, tc := range cases {
 		params := &mockedLanguageParams{