Skip to content

Commit e94cd83

Browse files
committedApr 28, 2021
Make export_schema_with_title argument immutable
1 parent d884a5a commit e94cd83

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ and this project adheres to
196196
`StakingQuery::Validator`, `ValidatorResponse` and
197197
`QuerierWrapper::query_validator` to allow querying a single validator.
198198
([#879])
199+
- cosmwasm-schema: Make first argument non-mutable in `export_schema_with_title`
200+
for consistency with `export_schema`.
199201

200202
[#696]: https://github.com/CosmWasm/cosmwasm/issues/696
201203
[#697]: https://github.com/CosmWasm/cosmwasm/issues/697

‎contracts/ibc-reflect/examples/schema.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ fn main() {
1818
export_schema(&schema_for!(QueryMsg), &out_dir);
1919
export_schema(&schema_for!(PacketMsg), &out_dir);
2020
export_schema_with_title(
21-
&mut schema_for!(AcknowledgementMsg<BalancesResponse>),
21+
&schema_for!(AcknowledgementMsg<BalancesResponse>),
2222
&out_dir,
2323
"AcknowledgementMsgBalances",
2424
);
2525
export_schema_with_title(
26-
&mut schema_for!(AcknowledgementMsg<DispatchResponse>),
26+
&schema_for!(AcknowledgementMsg<DispatchResponse>),
2727
&out_dir,
2828
"AcknowledgementMsgDispatch",
2929
);
3030
export_schema_with_title(
31-
&mut schema_for!(AcknowledgementMsg<WhoAmIResponse>),
31+
&schema_for!(AcknowledgementMsg<WhoAmIResponse>),
3232
&out_dir,
3333
"AcknowledgementMsgWhoAmI",
3434
);

‎packages/schema/src/export.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub fn export_schema(schema: &RootSchema, out_dir: &Path) {
2020

2121
// use this if you want to override the auto-detected name of the object.
2222
// very useful when creating an alias for a type-alias.
23-
pub fn export_schema_with_title(schema: &mut RootSchema, out_dir: &Path, title: &str) {
24-
// set the title explicitly on the schemas metadata
25-
let metadata = &mut schema.schema.metadata;
26-
if let Some(data) = metadata {
27-
data.title = Some(title.to_string());
23+
pub fn export_schema_with_title(schema: &RootSchema, out_dir: &Path, title: &str) {
24+
let mut schema = schema.clone();
25+
// set the title explicitly on the schema's metadata
26+
if let Some(metadata) = &mut schema.schema.metadata {
27+
metadata.title = Some(title.to_string());
2828
}
29-
write_schema(schema, out_dir, &title);
29+
write_schema(&schema, out_dir, &title);
3030
}
3131

3232
/// Writes schema to file. Overwrites existing file.

‎packages/std/examples/schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ fn main() {
1111
remove_schemas(&out_dir).unwrap();
1212

1313
export_schema(&schema_for!(Timestamp), &out_dir);
14-
export_schema_with_title(&mut schema_for!(CosmosMsg), &out_dir, "CosmosMsg");
14+
export_schema_with_title(&schema_for!(CosmosMsg), &out_dir, "CosmosMsg");
1515
}

0 commit comments

Comments
 (0)
Please sign in to comment.