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

docs: change docs about vectors #895

Merged
merged 3 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
8 changes: 7 additions & 1 deletion docs/src/types/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ You can use a vector just like you would use any other type -- e.g. a `[Vec<u32>

## Returning vectors

This is currently not supported. If you try returning a type that is or contains a vector you will get a compile time error.
Returning vectors from contract methods is supported transparently, with the caveat that you cannot have them nested inside another type.
iqdecay marked this conversation as resolved.
Show resolved Hide resolved

```rust,ignore
{{#include ../../../packages/fuels/tests/types.rs:returning_vec}}
```

** >Note: you can still interact with contracts containing methods that return vectors nested inside another type, just not interact with the methods themselves **
2 changes: 2 additions & 0 deletions packages/fuels/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,8 +1694,10 @@ async fn test_base_type_in_vec_output() -> Result<()> {
);
let contract_methods = contract_instance.methods();

// ANCHOR: returning_vec
let response = contract_methods.u8_in_vec(10).call().await?;
assert_eq!(response.value, (0..10).collect::<Vec<_>>());
// ANCHOR_END: returning_vec

let response = contract_methods.u16_in_vec(11).call().await?;
assert_eq!(response.value, (0..11).collect::<Vec<_>>());
Expand Down