Skip to content

Commit

Permalink
feat: implement Clone for TranslationOptions
Browse files Browse the repository at this point in the history
Since the struct does not implement the trait, it's difficult to reuse
the same options across multiple requests. The another way might include
to provided a custom `copy` or a `new` method that takes a reference to
the original struct, and creates a new with the same data. But since the
struct (1) does not contain any reference, (2) does not contain fields
which is hard or impossible to clone such as I/O resources, and (3) is a
fairly small so that the cost of clone is negligible.
  • Loading branch information
0x6b authored and mgruner committed Mar 16, 2023
1 parent 0de8283 commit 960847b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub struct LanguageInformation {
}

/// Translation option that controls the splitting of sentences before the translation.
#[derive(Clone)]
pub enum SplitSentences {
/// Don't split sentences.
None,
Expand All @@ -77,6 +78,7 @@ pub enum SplitSentences {
}

/// Translation option that controls the desired translation formality.
#[derive(Clone)]
pub enum Formality {
/// Default formality.
Default,
Expand All @@ -87,6 +89,7 @@ pub enum Formality {
}

/// Custom [flags for the translation request](https://www.deepl.com/docs-api/translating-text/request/).
#[derive(Clone)]
pub struct TranslationOptions {
/// Sets whether the translation engine should first split the input into sentences. This is enabled by default.
pub split_sentences: Option<SplitSentences>,
Expand Down

0 comments on commit 960847b

Please sign in to comment.