Skip to content

Commit

Permalink
feat(types): Query add new2 method
Browse files Browse the repository at this point in the history
Query should be created by new2 with IntoQuery trait
  • Loading branch information
tu6ge committed Aug 19, 2023
1 parent c13d7b3 commit e610aa2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/types/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DEFAULT_MAX_KEYS: usize = 100;
/// ```
/// use aliyun_oss_client::types::Query;
///
/// let query: Query = [("abc", "def")].into_iter().collect();
/// let query: Query = Query::new2([("abc", "def")]);
/// assert_eq!(query.len(), 1);
///
/// let value = query.get("abc");
Expand Down Expand Up @@ -53,12 +53,19 @@ impl Query {
///
/// The hash map is initially created with a capacity of 0, so it will not allocate until it
/// is first inserted into.
#[must_use]
pub fn new() -> Self {
Self {
inner: HashMap::new(),
}
}

/// Creates a new `Query` with trait
#[must_use]
pub fn new2<Q: IntoQuery>(into: Q) -> Self {
into.into_query()
}

/// Creates an empty `Query` with at least the specified capacity.
pub fn with_capacity(capacity: usize) -> Self {
Self {
Expand Down

0 comments on commit e610aa2

Please sign in to comment.