Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rust] Uncurry field types for object expressions #3901

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

* [GH-3900](https://github.com/fable-compiler/Fable/pull/3900) [Python] Fix nuget packages with hypens in their names (by @MangelMaxime)
* [Rust] Uncurry field types for object expressions (by @ncave)

## 4.21.0 - 2024-09-19

Expand Down
5 changes: 4 additions & 1 deletion src/Fable.Transforms/Rust/Fable2Rust.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,10 @@ module Util =
memberDecl
)

let fieldIdents = fieldsMap.Values |> Seq.toList
let fieldIdents =
fieldsMap.Values
|> Seq.map (fun ident -> { ident with Type = FableTransforms.uncurryType ident.Type })
|> Seq.toList

let fields =
fieldIdents
Expand Down
21 changes: 21 additions & 0 deletions src/fable-library-rust/src/FSharp.Collections.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace FSharp.Collections

open System.Collections.Generic

module HashIdentity =
let FromFunctions<'T> hasher equals : IEqualityComparer<'T> =
EqualityComparer<'T>.Create(equals, hasher)

let Structural<'T when 'T: equality> : IEqualityComparer<'T> =
EqualityComparer<'T>
.Create(LanguagePrimitives.GenericEquality, LanguagePrimitives.GenericHash)

let Reference<'T when 'T: not struct> : IEqualityComparer<'T> =
EqualityComparer<'T>
.Create(LanguagePrimitives.PhysicalEquality, LanguagePrimitives.PhysicalHash)

module ComparisonIdentity =
let FromFunction<'T> comparer : IComparer<'T> = Comparer<'T>.Create(comparer)

let Structural<'T when 'T: comparison> : IComparer<'T> =
Comparer<'T>.Create(LanguagePrimitives.GenericComparison)
1 change: 1 addition & 0 deletions src/fable-library-rust/src/Fable.Library.Rust.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Compile Include="Choice.fs" />
<Compile Include="Util.fs" />
<Compile Include="FSharp.Control.fs" />
<Compile Include="FSharp.Collections.fs" />
<Compile Include="System.fs" />
<Compile Include="System.Collections.Generic.fs" />
<Compile Include="System.Text.fs" />
Expand Down
Loading