Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depreciated legacy tree map #963

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions near-sdk/src/collections/legacy_tree_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Legacy `TreeMap` implementation that is using `UnorderedMap`.
//! DEPRECATED. This implementation is deprecated and may be removed in the future.
#![allow(clippy::all)]
// This suppresses the depreciation warnings for uses of LegacyTreeMap in this module
#![allow(deprecated)]

use borsh::{BorshDeserialize, BorshSerialize};
use std::ops::Bound;
Expand All @@ -18,6 +20,7 @@ use crate::IntoStorageKey;
/// - `above`/`below`: O(log(N))
/// - `range` of K elements: O(Klog(N))
///
#[deprecated(since = "4.1.0", note = "Use tree_map::TreeMap instead")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it's not that simple. Just swapping to use this type is a state-breaking change. At least the note should indicate this.

Also, the tree_map module is not exposed, so you might want to change this to say near_sdk::collections::TreeMap instead.

Optionally, this PR could introduce some migration of the old collection to the new one as a method, for example something like LegacyTreeMap::to_tree_map(&self) or something like this and then this comment can point to this to make the migration easy. This is less important, though, as I presume no one is really using this and if they absolutely want it, they can just ignore the deprecation warnings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many mistakes in one line!

#[derive(BorshSerialize, BorshDeserialize)]
pub struct LegacyTreeMap<K, V> {
root: u64,
Expand Down
1 change: 1 addition & 0 deletions near-sdk/src/collections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
//! that seemlessly integrated with the rest of the Rust standard library.

mod legacy_tree_map;
#[allow(deprecated)]
pub use legacy_tree_map::LegacyTreeMap;

mod lookup_map;
Expand Down