> For the complete documentation index, see [llms.txt](https://move-developers-dao.gitbook.io/aptos-move-by-example/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://move-developers-dao.gitbook.io/aptos-move-by-example/basic-concepts/struct-and-its-abilities.md).

# Struct and its Abilities

Struct is a way of defining custom type in move. It can be described as a simple key-value storage where key is a name of property and value is what's stored.

Syntax:

```rust
struct NAME has Abilities
{
    FIELD1 : TYPE1,
    FIELD2 : TYPE2,
    ...
}
```

**Struct** can have up to 4 abilities which define how values of this type can be used, dropped or stored.

* **Copy** - value can be *copied* (or cloned by value).
* **Drop** - value can be *dropped* by the end of scope.
* **Key** - value can be *used as a key* for global storage operations.
* **Store** - value can be *stored* inside global storage.

{% hint style="info" %}
Abilities for Primitive types like *integers*, *vector*, *addresses* and *boolean*  are pre-defined and unchangeable : *copy*, *drop* and *store*.
{% endhint %}

```rust
module my_addrx::Application {
	use std::vector;
        use std::debug;
	use std::string::{String,utf8};

	struct Users has key,drop {
		list_of_users: vector<User>    //storing the list of the users
	}

	struct User has store,drop,copy {
		name:String,                   //information required for a typical user
		age:u8
	}

        //creating a user by adding the user to the existing list and returning the user
	public fun create_user(newUser: User,users: &mut Users): User{
		vector::push_back(&mut users.list_of_users,newUser);
		return newUser
	}
	
	#[test]
	fun test_create_friend(){
		let user1 = User {
			name:utf8(b"Tony"),
			age:50,
		};
		
        let users = Users{
			list_of_users: vector::empty<User>()
		};

		let createdUser = create_user(user1,&mut users);
        debug::print(&users);
        assert!(createdUser.name == utf8(b"Tony"),0);
	}
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://move-developers-dao.gitbook.io/aptos-move-by-example/basic-concepts/struct-and-its-abilities.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
