Skip to content

Commit

Permalink
fix rust use
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Nov 10, 2024
1 parent 2cb59e8 commit 043bb3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/Generator/Rust.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ protected function writeHeader(DefinitionTypeAbstract $origin, Code\Name $classN
private function getImports(DefinitionTypeAbstract $origin): array
{
$imports = [];
$imports[] = 'use serde::{Serialize, Deserialize};';

if ($origin instanceof StructDefinitionType) {
$imports[] = 'use serde::{Serialize, Deserialize};';
}

$refs = TypeUtil::findRefs($origin);
foreach ($refs as $ref) {
Expand Down
2 changes: 0 additions & 2 deletions tests/Generator/resource/rust/default/meta.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
use serde::{Serialize, Deserialize};

pub type Meta = std::collections::HashMap<String, String>;

6 changes: 3 additions & 3 deletions tests/Generator/resource/visualbasic/default/News.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Public Class News
Public Property Meta As Meta

<JsonPropertyName("sendDate")>
Public Property SendDate As DateString
Public Property SendDate As DateAndTime.DateString

<JsonPropertyName("readDate")>
Public Property ReadDate As DateAndTime
Public Property ReadDate As DateAndTime.DateAndTime

<JsonPropertyName("price")>
Public Property Price As Double
Expand All @@ -51,7 +51,7 @@ Public Class News
Public Property Version As String

<JsonPropertyName("coffeeTime")>
Public Property CoffeeTime As TimeString
Public Property CoffeeTime As DateAndTime.TimeString

<JsonPropertyName("g-recaptcha-response")>
Public Property Captcha As String
Expand Down

0 comments on commit 043bb3a

Please sign in to comment.