Repository: paritytech/substrate
File: frame/nfts/src/features/create_delete_item.rs (Rust)

Code before:
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::*;
use frame_support::{pallet_prelude::*, traits::ExistenceRequirement};

impl<T: Config<I>, I: 'static> Pallet<T, I> {
	/// Mint a new unique item with the given `collection`, `item`, and other minting configuration
	/// details.
	///
	/// This function performs the minting of a new unique item. It checks if the item does not
	/// already exist in the given collection, and if the max supply limit (if configured) is not
	/// reached. It also reserves the required deposit for the item and sets the item details
	/// accordingly.
	///
	/// # Errors
	///
	/// This function returns an error in the following cases:
	/// - If the collection ID is invalid (`UnknownCollection`).
	/// - If the item already exists in the collection (`AlreadyExists`).
	/// - If the item configuration already exists (`InconsistentItemConfig`).
	/// - If the max supply limit (if configured) for the collection is reached
	///   (`MaxSupplyReached`).
	/// - If any error occurs in the `with_details_and_config` closure.
	pub fn do_mint(
		collection: T::CollectionId,
		item: T::ItemId,
		maybe_depositor: Option<T::AccountId>,
		mint_to: T::AccountId,
		item_config: ItemConfig,
		with_details_and_config: impl FnOnce(
			&CollectionDetailsFor<T, I>,
			&CollectionConfigFor<T, I>,
		) -> DispatchResult,
	) -> DispatchResult {
		ensure!(!Item::<T, I>::contains_key(collection, item), Error::<T, I>::AlreadyExists);

		Collection::<T, I>::try_mutate(
			&collection,
			|maybe_collection_details| -> DispatchResult {
				let collection_details =
					maybe_collection_details.as_mut().ok_or(Error::<T, I>::UnknownCollection)?;


Review comment (suggestion):
```suggestion
	/// This function returns a `Dispatch` error in the following cases:
```

Code after:
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::*;
use frame_support::{pallet_prelude::*, traits::ExistenceRequirement};

impl<T: Config<I>, I: 'static> Pallet<T, I> {
	/// Mint a new unique item with the given `collection`, `item`, and other minting configuration
	/// details.
	///
	/// This function performs the minting of a new unique item. It checks if the item does not
	/// already exist in the given collection, and if the max supply limit (if configured) is not
	/// reached. It also reserves the required deposit for the item and sets the item details
	/// accordingly.
	///
	/// # Errors
	///
	/// This function returns a dispatch error in the following cases:
	/// - If the collection ID is invalid ([`UnknownCollection`](crate::Error::UnknownCollection)).
	/// - If the item already exists in the collection
	///   ([`AlreadyExists`](crate::Error::AlreadyExists)).
	/// - If the item configuration already exists
	///   ([`InconsistentItemConfig`](crate::Error::InconsistentItemConfig)).
	/// - If the max supply limit (if configured) for the collection is reached
	///   ([`MaxSupplyReached`](crate::Error::MaxSupplyReached)).
	/// - If any error occurs in the `with_details_and_config` closure.
	pub fn do_mint(
		collection: T::CollectionId,
		item: T::ItemId,
		maybe_depositor: Option<T::AccountId>,
		mint_to: T::AccountId,
		item_config: ItemConfig,
		with_details_and_config: impl FnOnce(
			&CollectionDetailsFor<T, I>,
			&CollectionConfigFor<T, I>,
		) -> DispatchResult,
	) -> DispatchResult {
		ensure!(!Item::<T, I>::contains_key(collection, item), Error::<T, I>::AlreadyExists);

		Collection::<T, I>::try_mutate(
			&collection,
			|maybe_collection_details| -> DispatchResult {
				let collection_details =