Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Made API to create field accept String #643

Merged
merged 2 commits into from
Nov 28, 2021
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
12 changes: 6 additions & 6 deletions src/datatypes/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ impl PartialEq for Field {
}

impl Field {
/// Creates a new field
pub fn new(name: &str, data_type: DataType, nullable: bool) -> Self {
/// Creates a new [`Field`].
pub fn new<T: Into<String>>(name: T, data_type: DataType, nullable: bool) -> Self {
Field {
name: name.to_string(),
name: name.into(),
data_type,
nullable,
dict_id: 0,
Expand All @@ -73,15 +73,15 @@ impl Field {
}

/// Creates a new field
pub fn new_dict(
name: &str,
pub fn new_dict<T: Into<String>>(
name: T,
data_type: DataType,
nullable: bool,
dict_id: i64,
dict_is_ordered: bool,
) -> Self {
Field {
name: name.to_string(),
name: name.into(),
data_type,
nullable,
dict_id,
Expand Down
5 changes: 3 additions & 2 deletions src/datatypes/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ use super::Field;
/// An ordered sequence of [`Field`] with optional metadata.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Schema {
pub(crate) fields: Vec<Field>,
/// The fields composing this schema.
pub fields: Vec<Field>,
/// A map of key-value pairs containing additional meta data.
pub(crate) metadata: HashMap<String, String>,
pub metadata: HashMap<String, String>,
}

impl Schema {
Expand Down