Skip to content

Commit

Permalink
refactor: new -> default
Browse files Browse the repository at this point in the history
  • Loading branch information
laysakura committed Apr 5, 2023
1 parent 397c8d0 commit 15b7c93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sdks/rust/src/tests/primitives_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod tests {
KV::new("a".to_string(), 2),
KV::new("b".to_string(), 3),
]))
.apply(GroupByKey::new())
.apply(GroupByKey::default())
.apply(AssertEqualUnordered::new(&[
KV::new("a".to_string(), vec![1, 2]),
KV::new("b".to_string(), vec![3]),
Expand Down
6 changes: 3 additions & 3 deletions sdks/rust/src/transforms/group_by_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use std::marker::PhantomData;
use std::sync::Arc;

use crate::elem_types::ElemType;
use crate::elem_types::kv::KV;
use crate::elem_types::ElemType;
use crate::internals::pipeline::Pipeline;
use crate::internals::pvalue::{PTransform, PValue};
use crate::internals::serialize;
Expand All @@ -35,8 +35,8 @@ pub struct GroupByKey<K, V> {
}

// TODO: Use coders to allow arbitrary keys.
impl<V: ElemType> GroupByKey<String, V> {
pub fn new() -> Self {
impl<V: ElemType> Default for GroupByKey<String, V> {
fn default() -> Self {
Self {
payload: serialize::serialize_fn::<Box<dyn serialize::KeyExtractor>>(Box::new(
Box::new(serialize::TypedKeyExtractor::<V>::default()),
Expand Down
2 changes: 1 addition & 1 deletion sdks/rust/src/transforms/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<T: ElemType + PartialEq + Ord + fmt::Debug> PTransform<T, ()> for AssertEqu
.apply(ParDo::from_map(|x: &Option<T>| -> KV<String, Option<T>> {
KV::new("".to_string(), x.clone())
}))
.apply(GroupByKey::new())
.apply(GroupByKey::default())
.apply(ParDo::from_dyn_map(Box::new(
move |kvs: &KV<String, Vec<Option<T>>>| {
let mut actual: Vec<T> = kvs
Expand Down

0 comments on commit 15b7c93

Please sign in to comment.