Squashed 'third_party/flatbuffers/' changes from acc9990ab..d6a8dbd26

d6a8dbd26 Experimental fix for failing oss-fuzz coverage build (#6259)
ed391e177 BREAKING: Rust flexbuffers serde human readable set to false (#6257)
a49531414 Update to flags in fuzzing-cmake file (#6256)
de1f0342c Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)
d0d51e2a5 flatc should support --binary --schema with optional scalar fields. (#6252)
33ab26017 Bump version of rules_go to 0.24.5 (#6234)
febb9d87c Union As Accessors for C# (#6251)
8778dc7c2 Resets buffer without deallocating current pointer (#6247)
aae376e9a Add GetBufferSpan() function to bufferbuilder (#6235)
0ff047148 Modernize android build and sample (#6229)
46a8c7e95 Added required-nested-flatbuffer to monster_test and fixed rust (#6236)
bc56c553e Notify based on Labelling issues and PR (#6241)
07d7cd78a Converted globs to use single quotes (#6240)
cdef70e24 More adjustments to the auto labeler (#6239)
9dd44df35 Updated Lua labeller glob (#6238)
c9b29d088 Support size-prefixed buffers and add tests for size-prefixed messages (#6232)
fba93e0ab Removes duplicate swift in labeler (#6228)
d1a545b1f Added more labels for auto labeler (#6227)
ea92a668d [C#] Optional Scalars (#6217)
6034de286 [Label Bot] Add Java and Kotlin support for the label bot (#6226)
b08b0a440 Implement `Debug` trait for Rust flatbuffers. (#6207)
17ae48dec [Label Bot] Adds some languages to labeler bot (#6222)
fc8097925 Auto Labeler Setup, Just C# for now (#6221)
55658f523 Auto Labeler Setup, Just C# for now (#6218)
14ecfe423 Updated comments and fixed a fundamental type error. (#6214)
a0182cdb1 optional scalars for ts/js (#6215)
0dfcc0a37 Adds NetTest.bat to run .NET Core tests on Windows (#6216)
f9a18ea63 [Java] Implement optional scalars (#6212)
c7586e85a Empties the sharedString map on reset on go and csharp (#6187)
914c64601 Removed C# references from java generator. Move annotations closer to definitions (#6204)
42d7c7997 Adds readable size to asserts in read functions (#6210)
e68e8d7de Refactor idl_gen_rust (#6206)
84809be7e Fix typo in flatbuffers::span declaration. (#6202)
1606fb637 Kotlin test optional enum (#6201)
fe8e3c7e5 Mass Refactoring to use `IsString` and other BASE_TYPE helpers (#6193)
8f6fa4b71 Updated SupportsAdvancedUnionFeatures to look out for string (#6190)
b46db38f5 [JS/TS] Rewrite flexbuffers JS to TS (#6148)
9fa1d2705 Rework enums in rust. (#6098)
a402b3aba idl_gen_json_schema Fix generation of arrays of enums (#6184)
0e1415b99 fix(go_test): remove deprecated grpc call (#6183)
5cd713710 Add generation of JSON Schema to library (#6165)
5be777e1d Bump junit from 4.12 to 4.13.1 in /grpc/tests (#6173)
a49d440ec Bump junit from 4.12 to 4.13.1 in /grpc (#6172)
4ec5e8db9 [C++] Add option to not generate direct copy methods. (#6166)
04bec23a3 Add Array initialization from struct constructor (#5865) (#6147)
77d57fd07 Cast to right type for reserved_ subtraction (#6167)
543c1bbeb Fixed rust nested flatbuffers for tables other than self (#6062)
cb971eece [C++] Fix -Wnarrowing and -Woverflow due to signed bitfields on G++ ARM (#6163)
7b9e61fcc [TS] GRPC  Implementation (#6141)
3359e3042 Moved C++ to optional_scalars2 and added some tests. (#6162)
187a4787f [Rust] Upgrade flatbuffers library to 2018 edition (#6159)
08943aa26 Flatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)
5975658eb Enables optional enums in swift (#6160)
5d3cf440e Updated Lobster test for optional bools/enums
8ec8322f0 Ruopt enum (#6156)
bbcc85fd4 Fix generation of C++ code with Optional<Enum> (#6155)
0bdf2fa15 [C#] Fix and improve project files (#6142)
2eedc769d possibility to create a vector from an iterator (#6135)
ab01ae162 flatc should output a warning, when an attribute is attached more than once (#6146)
689bfafa7 [Python/JS/TS] Codegen SizeOf method for structs (#6136)
641309a5b unix2dos on tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj (#6133)
52e362879 SpanT is available in .Net Standard 2.0. (#6137)
dca12522a Add static cast to avoid implicit double promotion. (#6132)
e0bbaa6f9 [C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)
ab139d6be Revert "[C#] Fix and improve project files (#6116)" (#6130)
34d67b425 Minireflect fixed array (#6129)
96d5e3597 [JS/TS] fix flatbuffers default export (#6123)
eb686a86f Add missed file generated by optional_scalar.fbs (#6125)
750281630 [C#] Fix and improve project files (#6116)
fb4e1c34f Add CharToLower and CharToUpper into util.s (#6126)
8c67b5b12 Add support of Optional<T> scalars to C++ code generator (#6092)
6228b66d3 [Kotlin] Support for optional scalars. (#6115)
e1be8aaad Bump version for latest swift version (#6121)
94873e595 [JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095)
b8e87fafe [JS] Add getFullyQualifiedName() (#6119)
f96d1ef74 [Java] allowing larger buffer sizes when growing a byte buffer (#6118)
89435303b [Swift] Migrates struct write APIS to write directly to the buffer (#6093)
c75ae2429 Optional-ness in reflection (#6097)
338944d3d Rename Nullable scalars to Optional scalars (#6112)
f5ab24bc4 Avoid memcpy call for empty vectors (#6111)
92a8c1a0f [JS] FlexBuffers Fix for wrong type of offset and length values (#6107)
6cea45dcd fix c# json serializer commandline argument docs (#6104)
fec58aa12 Fix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102)
71aca81ff [JS] FlexBuffers Support (#5973)
04d87ffec [C++] Small refactoring of the C++ code generator (#6091)
bb25956f0 Wrap verify file id condition in Check call (#6085)
49f4948f0 + Add `removable-media` plug to the snapcraft config (#6083)
eeacc53d2 Adds proper access types for swift object api & flatbuffers & grpc (#6081)
f3003e08d [Lobster] missed a test
d713a0084 [CMake] enabled multi-core builds in VS projects
77f966f89 [Lobster] optional scalars support
e86d5b8e9 [Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)
db2aa9b4e [C#] Cleaned up .NET testing script for Mono (#6016)
63cc0eec4 Adds a serialize helper function to native table (#6059)
c30a87de6 [TS] Fix four bugs with imported types in TypeScript. (#6054)
a0fb30575 [Swift] Append namespace for Swift Grpc implementation (#6049)
77c18c1d6 export a __version__ variable for python module (#5309)
f1f23d08e adding fb import when no other imports are present (#6030)
f1025b284 [Feature] Checks for Nullable strings (#6050)
5d052f4e5 [Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (#6045)
18b015d25 Rust codegen improvements and lint fixes (#6046)
d76e93f27 adds code gen for optional scalars in swift (#6038)
82fac326c [C++] Fix compiler error from deleted assignment operator (#6036) (#6047)
043b52bd4 Optional Scalars support for Rust (#6034)
c8fa0afdf Allow to run cpp tests under grpc/tests/ using bazel. (#6040)
6d0aae73c Fix git command executed in wrong folder when doing cmake superbuild (#6039)
ff1b73128 [Swift] Optional Scalars Preparation (#6028)
2e48c8dd3 tests: Check for both quiet and signaling NaN on mipsel/hppa (#6029)
6942704f2 support deprecated flag in json schema (#6022)
9ecd2e16c Flatc parser support for nullable scalars (#6026)
33e2d8079 [Dart] Generate constant values map for enums (#6025)
969d0f7a6 Using proper symbol name for reexport (#6021)
515a4052a Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020)
36fbe6f13 Updated FB import (#6019)
b69fc8cc9 [Java] Add support for shared strings on FlatBufferBuilder. (#6012)
ab6af18d9 Not using non-existent create method for obj api (#6015)
37a5dee10 Code cleanup + updates test and readme (#6004)
8a721f69a Serde with bytes maps to Blob (#6009)
e810635ea [Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)
4995e1527 Manage grpc dependency in Bazel's WORKSPACE file. (#5995)
60b6066fe Add warning to schema parser if field name is not snake_case. (#6005)
35d45cac7 [Rust] Flexbuffers dependency cleanup and fixes (#5998)
165a6e3d1 Re-added Evolution Schema Code Generation Command (#5999)
13d3fb2ea Fix RPM install conflict (#6003)
d64078eb2 [Swift] Initialize memory when clear ByteBuffer (#5982)
ca1190a3d [TS] Use proper TypedArray in create*Vector (#5991)
7571b2ac5 [C++] Updates real_path to be truly portable (#5787)
e5a8f76a4 [C++] Generate default member initializers for >= C++11 (#5989)
413bb9b55 [Kotlin] Fix Access to union of vector element (#5994)
f35184aef [Swift] Add parsing from unowned UnsafeMutableRawPointer for ByteBuffer (#5981)
b124b7625 Removed requirement that enums be declared in ascending order. (#5887)
0ec7600c6 Do not remove the last digit from float values (#5974)
14baf45c9 Mark GetBufferMinAlignment() const (#5985)
9abb2ec2c TypeScript/JavaScript docs improvements (#5984)
2e57d80b1 [Swift] Internal library improvements (#5965)
cfc7753a4 [Doc] Added missing letters to compiler options (#5976)
12ddc8a92 Rust Flexbuffers Documentation update (#5979)
24ad35709 [docs] typo: updates monsterdata.json to be valid json (#5978)
cc44a4442 [idl_parser] Mark typefield as deprecated (#5958)
9ab4a5c0e Deleted old stale bot
6682cfe87 Increased Operations per run in stale.yml
64922904b Adding Stale Action to clean up PR and Issues
8e505cb67 [C++] Fixed/Enabled --cpp-ptr-type std::shared_ptr [#5813] (#5959)
a28357d7a Propagate boolean default values from proto to fbs (#5964)
7cb4762a6 [Swift] Improving reallocation time by using memcpy and moving reallocation code to storage (#5960)
4e45f7c9e Fix error in SimpleQSort (#5955)
7ac026405 fix error on GRPC Python - ignore namespace tree if not specified (#5862) (#5922)
108e981db Required is now implemented in swift (#5952)
94a78e385 Fixed: Access violation and ASAN/UNSAN failures with sorted tables
53fb453e0 [rust] Add FlatBufferBuilder::force_defaults API (#5946)
17c1f35fa [FlexBuffer][Java] ReadWriteBuf and ReadBuf interface public (#5948)
2eaf57778 [Java] Grow ArrayReadWriteBuf enough to match requested capacity. (#5921)
666800da3 Adds bool support in structs + updates grpc support + CI upgrades (#5943)
38ed69eb3 fixed mutating inline values (#5942)
d026e6f07 Add static asserts to ensure that reflection API arrays are kept in sync (#5934)
988164f6e [C++] Got rid of memset's in constructors (#5938)
7179a5a8b General Codebase clean up (#5939)
a0da0c08c Add GetStringView like GetString, GetCstring (#5937)
ac203b209 [C#] Add file identifier to ObjectAPI Serialization Utility. (#5920)
8dd1bf25b not creating creation methods when using structs (#5919)
5aa443d98 [Dart] Adding FlexBuffers support (#5853)
0fa087657 [Dart] Getting tests/DartTest.sh to work on master. (#5915)
424a473e1 Schema parser: prohibit declaration of an array of pointers inside structs (#5907)
c3faa8346 Fix Cargo.toml dependencies (#5911)
91399ad05 fix union type names (#5902)
32782e4ad Update Rust Flexbuffers metadata before publishing (#5905)
e7f3b1690 [TS] Make Obj-API work with --short-names (#5898)
12ed1fe4a fixed invalid imports with --gen-all (#5895)
85ee4df7a [C#] Thread safe reads of Double and Float values from a ByteBuffer (#5900)
de89bd193 Implement flexbuffers in python (#5880)
8be05f6bd Rust Flexbuffers (#5669)
870ecbc09 [swift] Moves code to use VTablesStorage (#5888)
c2da8d5d8 [Java][FlexBuffers] Make FlexBuffersBuilder reusable by adding clear() (#5889) (#5890)
e84cbff67 Align package name to FindFlatBuffers.cmake (#5899)
f94e6c84e Small tutorial improvements - documentation only (#5894)
f12cca8bc Attempt at adding Github Actions CI
7e4124d6e Handle git program or .git folder absence (#5878)
a875d247a only add native_include_files if object based api is enabled (#5886)
6e9f5d981 Respect shared attribute in Parser (#5885)
ff1c78233 include/flatbuffers: typo fixes in comments (#5884)
2e9a19673 Updates swift docs for package management (#5883)
e3cb07d32 [Rust] idl_gen_rust.cpp: (Option/required-aware codegen for unions) (#5850)
712866d57 Propagate use_string_pooling in CopyTable (#5879)
44c919a9e Not using reexports with --gen-all (#5873)
99aa1ef21 Added INCLUDE_PREFIX option for flatbuffers_generate_headers (#5866)
40ba170c9 Fixed text in internals doc that implied structs can be root
cb4d0f72e [Swift] Object API support  (#5826)
003e16405 [TS] Add Obj API (#5788)
21cf300f4 fix cpp usage markdown error (#5845)
9655e12d6 Upgraded swift implementation for grpc (#5843)
fb96fadc2 [C#] Fix nested structs and arrays in Object API (#5765)
408f11fbd [ts] Fix empty source/dest namespaces when reexporting. (#5841)
a83caf591 Improves performance for the swift library by using structs + a storage class (#5835)
925fab6b1 [Java][FlexBuffers] Optimize Map access (#5735)
d9fecc332 [CMake] : Add precompiled header support with FLATBUFFERS_ENABLE_PCH (#5827)
e9d453240 Added flatbuffers_generate_headers and flatbuffers_generate_binary_files cmake functions. (#5830)
c37c989ed Correct calculation of vector element size (#5831)
6b271b7ec Fix Clang-trunk warnings about special members deprecated in C++20. (#5829)
90f3b8e8c Fix `float_constant` definition in './doc/Grammar.md` (#5828)
3af735934 [csharp] flatc should generate a 'Create…' method for tables with struct field… (#5818)
c4231c3cb Updated doxyfile - added missing files (#5824)
9657df184 Update Grammar.md (#5820)
97ffc590e Include CPack only when explictly packaging (#5817)
8b52af65b [C++] Add max_depth and max_tables parameters to reflection::Verify (#5815)
9b034eee1 Fix interpretation of 'nan(number)' by the idl_parser (#5810)
3e9ac3cff [Scripts] Adds swift to generated code (#5806)
697147a2e updated maven build files
6df40a247 pre-tag version bump for 1.12
0dba63909 Removes the inner loop in the endtable check written tables (#5803)
0e3fdd0ee Escape characters in jsonschema descriptions (#5644)
45a2b07cb Remove `noexcept` qualifier copy-ctor of `union` type (#5800) (#5802)
d10c16314 Replace 'assert' by 'FLATBUFFERS_ASSERT' inside idl_parser.cpp (#5799)
35abb7f89 Add non-nullable modifier to return type of functions never returning null (#5797)
9954e09ab [C++] Generate code for vector force_align attribute. (#5796)
95a21327f rust: pub export the VectorIter type (#5736)
89b6183ee Fix Python min alignment
5a98d65e8 [Rust] Add gen-name-strings for Rust (#5757)
f73d205bc Removed assert that wasn't backwards compatible.
7c37abe92 [C#] add ObjectAPI Serialization Utility (#5785)
4749e77b0 Fixed docs on how to obtain parser error.
6ff189841 Added --filename-suffix and --filename-ext to flatc (#5778)
c9a30c9ca Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case. (#5777)
8c02d17be Skip writing reflection_generated.h if not changed (#5776)
34305c4ce [Swift] Adds GRPC to Swift (#5758)
cd88e6b2a [Java][FlexBuffers] Abstract buffer access from ByteBuffer (#5743)
3ec7a53c6 Adds cocoapods and a readme of how to get the package (#5771)
6d44cede7 [snap] Fix versioning (#5727)
cc08c0835 [Python] Fixed potential allignment issue (#5768)
54f8b787c Fix memory leak on cpp object api (#5761)
17557f913 [Python] Fixed issue #5499 (#5764)
d54af8cd4 [C++] Use strong enum type for vectors when scoped-enums is on. (#5750)
173e10fdf [C#] support Json Serialization (#5752)
8f56990f6 FlexBuffers: C++: scalar-only typed vectors were not aligned.
6400c9b05 Bump Rust port to 0.6.1 (#5747)
7418d8587 [C#] support Object API (#5710)
c580fa284 Adds min and max, comments, and all of swift's keywords + fix docs (#5737)
f2a127230 Use VS 2017 and 2019 on CI, fix cast issue in dart_idl (#5740)
316d7c208 Creates a flatbuffers validation function + small fix (#5725)
47026ea6b Added the code to embed the binary schema to the source (--bfbs-gen-embed). (#5701)
3f677f241 [Java][FlexBuffers] Deprecate typed vector strings due to design flaw (#5722)
a593a11e5 [Go] Implements a SharedStrings function (#5733)
7cdfc8475 [Swift] Fix padding function overflow when bufSize is 0 (#5721)
bab2b0db4 Add vcpkg installation instructions (#5732)
89418eb84 [Dart] Fix deprecated field support, inf/nan (#5724)
9cadf05d8 [typescript] Size-prefixed root accessors not taking into account size prefix (#5717)
6da1cf79d [rust] Add use declarations to Rust-generated bindings for imported FB definitions (#5645)
bee1df96d [Go] Replace references to hardcoded ”Monster" etc with idiomatic go wherever possible (#5716)
01189d7ed [C++] Fix for printing of enum in case output_enum_identifiers=1. (#5706)
c4b2b0a25 [Swift] Support create long string (#5709)
a4b2884e4 Added create function for swift (#5707)
04d80f255 [Swift] Swift implementation 🎉🎉 (#5603)
55686100a Changed direct calls to strtod to use StringToNumber
718351831 Document JSON compatibility guarantees. (#5704)
d1b34f0f2 Add CMake 'generated_code' target to simplify resolution of build dependencies (#5697)
21b706196 (Optionally) add an additional suffix namespace to generated fbs files. (#5698)
35daaf83d [Java] Replace Table.UTF8_CHARSET with StandardCharsets.UTF_8 (#5696)
3b458f7a1 Rust: Temporarily disable 2 endianness unit tests (#5695)
a5d9d0f7d [C++17] Add Traits class for Tables and Factory function within it. (#5678)
3cd9b6434 Removed code_generators.cpp from library targets
355dfd48d [rust] Make enum names public (#5690)
bcd58a159 Correct inverted logic around include prefixes. (#5689)
a2c12900a Optimize Pack method using numpy (#5662)
901b89e73 [C++] Add Builder and Table typedefs (#5685)
31f879908 Minor doc updates: FlexBuffers C#, Discord, CppUsage.
8023d99e2 Upgrade rules_go (#5684)
b4154405d Fix --incompatible_load_cc_rules_from_bzl (#5683)
04c17c7a7 Add support for absl::string_view when available (#5682)
62ec7d52c [Bazel] Add support for compatible_with and restricted_to (#5681)
7de668053 CI: New Docker tests for Python with numpy (#5677)
3a70e0b30 Fixed struct initialization error on older versions of C#
9b1320135 Fixed warnings in FlexBuffers.java
5e3916050 Fixed out of date licenses on gRPC Python files.
c95755051 Removed test proto output.
44bf71988 Add flatc '--cpp_std' switch (#5656)
3e8f15df9 Fix for FlexBuffers FBT_VECTOR_STRING size bit-width.
602721a73 Added Check to VerifyAlignment (#5675)
13c05f4da Improve import handling for proto conversion (#5673)
ce3a1c43a [Dart] Fix prepare space for writeListInt64 and writeListUint64 (#5654)
aa75e5734 Make Rust constants public (#5659)
2790fee25 Add namespace qualification to union types (#5666)
eddebec1b Bugfix for Rust generation of union fields named with language keywords (#5592)
030fee36a wrap multiple statements in do {} while(!IsConstTrue(true)) (#5655)
f9724d1bd [gRPC] Uncomment MessageBuilder (#5658)
b20801ca4 Supress unsigned-integer-overflow for PaddingBytes (#5647)
a8e800bd7 Add --force-empty-vectors option (#5653)
d7530ae96 Fixed enum min/max values not properly escaped.
99d11e279 Split Bazel targets into multiple packages (#5640)
4fd8eb214 Remove a static_assert (#5643)
65f870357 Flatbuffers Python Object API (#5616)
75823cc27 [Clang 10]: definition of implicit copy constructor for 'TableKeyComparatoris deprecated #5649 (#5650)
58e279244 [docs]: add missing semicolon (#5648)
3c964e10a [GO] Fix support for enums with underscores and Unions with imported members (#5600)
c3c32ec94 Fix ambiguity of a type deduction in TEST_EQ macro if arguments have `enum class` type. (#5630)
075e8d676 Simplify declarations of x-macro FLATBUFFERS_TD (#5638)
bcf1bd5c9 read vtable size through ReadScalar() (#5636)
136d75fa6 Changed null checks in test. Removed verifier pointer usage (#5634)
091fa1fd1 Add testing of C++ with sanitizers (CI-Docker) (#5631)
ff3781dc2 add namespace prefix in FLATBUFFERS_MAX_BUFFER_SIZE (#5629)
6beb9f49c Support for python grpc - continuing the work from the pull request #4270 #4705 (#5613)
80988ea86 Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625)
0f2ff7eaa Lua cleanup (#5624)
dda095023 [C++] Adds basic schema evolution tests (#5611)
adbcbba5d [C++, C#, Java] Separated C# and Java generators into their own classes (#5618)
cbbd6aca0 add check for root_type specified for json schema generation (#5622)
405c64e07 [Rust] Bump smallvec version to 1.0 (#5621)
42c08cbca Ran src/clang-format-all.sh (#5617)
33d5dd9bd Improved pull request & clang-format instructions.
105dd528e Change monster_extra generation to use flatbuffers::unique_ptr (#5612)
f0f0efe7b [C++] Refactor to conform to Google C++ style guide (#5608)
e837d5a29 Fixed deprecated method in GRPC Java test.
9834ee978 Fixed Apache license not using canonical version.
44b2ab087 include/flatbuffers/base.h: fix no_sanitize issue with old clang (#5610)
46ae3f80a [C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (#5599)
7b38aa71e flatbuffers.h: fix documentation warning (#5607)
661bedd83 Add Lua FlatbufferBuilder Clean() method to enable reuseable builders (#5606)
8526e12d7 [Kotlin] Fix union vector accessor after change in Java API (#5605)
3c7b660d6 [flatc] Remove an always true condition for flexbuffers (#5604)
964365ba6 [Go] Add UnPackTo functions (#5598)
32254b7ac [Go] Object API support (#5339)
521e255ad Rust: Add idiomatic iterator for Vector type (#5579)
1b85292fd Fix typos in comments (#5590)
480815447 C++ verifier for evolved union fields should return true (#5586)
8d5e424c6 Add ByteBuffer copy for vector of bytes in Java (#5587)
b4774d235 Rust: Fix Copy and Clone impls for a few generic types (#5577)
26f238c24 Add `--clean-first` to the cmake-build command (travis) (#5574)
e93c8c46e Fix Follow implementation for bool (#5554)
e21516b9d Fix issue #5557 (#5573)
fbc11e8ae Avoid intentional unsigned integer overflow getting caught by sanitizers (#5572)
e9d29c21a Python: Add forceDefaults opt to python Builder (#5564)
8bfafc76d Java: Don't annotate vector-of-tables item getters with @nullable. (#5562)
df3e8bf4a Fixed warnings generated by recent JSON sorting feature.
5665cfe49 [Java] byte buffer factory returned buffer capcity is used instead of the requested size (#5558)
5797540ed #5544 Fix of Array of table is not sorted if Create<type>Direct() is used (#5546)
7f1af7cb0 Fix build with gcc version 7.4.0 (#5570)
32f47ad24 Fixed JSON parser not sorting vectors of tables/structs with key.
842f672ba [FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)
d4cae0a62 Fix issue #5542 (#5543)
f1147f65b Fixed Android STLPort related error.
69d3fec48 Fix namespaced struct/field name collision detection (#5540) (#5545)
cfb4ecf6f [flac] Add FlexBuffers option for generating data (#5519)
a92039687 Update Rust versions under test from 1.30.1 to 1.37.0 (#5538)
625338d09 Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat (#5529)
3f8ce99c5 [FlexBuffers][Java] Add override Key::toString (#5533)
0798b7b69 [FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)
cbdf82e2f Fix Mutate() methods of Array<scalar/struct> (override 5508) (#5526)
e365c502f Java: Added access object for vector of struct and vector of tables. (#5233)
97f3aa917 Fixed DetachedBuffer self move assignment (#5521)
2f5bb2eec Fix buildifier warnings found in new bazel (#5517)
917687c7a Fixed Reflection Verifier not handling vectors of unions.
f9277e691 Fixed GenerateText not handling vectors of unions.
2706381ee Add element size parameter to __vector_as_arraysegment [c#] (#5512)
b5560fcd5 [Java][FlexBuffers] Improve documentation for FlexBuffers in Java. (#5506)
782b865c5 Annotate getters with @Pure when --java-checkerframework is specified. (#5510)
3bfc86eaf [Dart]fix: segment fault with empty namespace when generating dart file (#5507)
c0282873f Rust: Fixed cargo clippy on non-generated code (#5485)
4b870aca9 [Javascript] Fix syntax error for signed enum (#5503)
d0e3870c0 [C#] Fix retrieving enumeration vectors as arrays (#5457)
fb25eb87f Doc typo fixes (#5505)
cb35d3a0e Use all of the available space in the buffer returned by ByteBufferFactory to allow the factory to keep a pool of larger than initialsize sized buffers. (#5500)
8e6cabb31 [FlexBuffers][Java] Implementation of FlexBuffers API (#5476)
bd31dd242 Clarified value reuse in FlexBuffers
65b67d213 Fixed test build invocation of arrays_test.fbs
1fbb71132 FlexBuffers: allow any values to be shared.
cd75a3658 Android: remove app_dummy() calls
ec6b0bf29 Fixed STLPort Android compile error
c11b5d744 [bugfix]flexbuffers isvector bugfix (#5488)
4525c91be Fix incorrect padding in arrays of structs (Issue #5484) (#5491)
b97b342f5 Fixed missing generated code.
c1058a903 C++ IDL generation adds superfluous semicolon in GenTablePost, causing (#5483)
303044934 [go]add Name() for ForceCodec  interface (#5486)
a2485d4ec reflection: check for valid union enum value during object verification (#5475)
a20e71ac9 has_method support for primitive fields in java runtime. Changed: idl.h, FlatBufferBuilder.java ,  idl_gen_general.cpp, idl_parser.cpp, flatc.cpp (#5468)

Change-Id: I836f4b43e6818bb16425a87899e6234ac86242aa
git-subtree-dir: third_party/flatbuffers
git-subtree-split: d6a8dbd26ff08a8868e0d0c1b4b67d31b40e4a7f
diff --git a/samples/SampleBinary.java b/samples/SampleBinary.java
index 555194f..f7052ae 100644
--- a/samples/SampleBinary.java
+++ b/samples/SampleBinary.java
@@ -95,6 +95,12 @@
       assert monster.weapons(i).damage() == expectedWeaponDamages[i];
     }
 
+    Weapon.Vector weaponsVector = monster.weaponsVector();
+    for (int i = 0; i < weaponsVector.length(); i++) {
+      assert weaponsVector.get(i).name().equals(expectedWeaponNames[i]);
+      assert weaponsVector.get(i).damage() == expectedWeaponDamages[i];
+    }
+
     // Get and test the `equipped` FlatBuffer `union`.
     assert monster.equippedType() == Equipment.Weapon;
     Weapon equipped = (Weapon)monster.equipped(new Weapon());
diff --git a/samples/android/AndroidManifest.xml b/samples/android/AndroidManifest.xml
deleted file mode 100644
index 352e0fa..0000000
--- a/samples/android/AndroidManifest.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (c) 2015 Google, Inc.
-
-     This software is provided 'as-is', without any express or implied
-     warranty.  In no event will the authors be held liable for any damages
-     arising from the use of this software.
-     Permission is granted to anyone to use this software for any purpose,
-     including commercial applications, and to alter it and redistribute it
-     freely, subject to the following restrictions:
-     1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-     2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-     3. This notice may not be removed or altered from any source distribution.
- -->
-<!-- BEGIN_INCLUDE(manifest) -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.samples.FlatBufferSample">
-
-    <uses-feature android:glEsVersion="0x00020000"></uses-feature>
-
-    <!-- This .apk has no Java code itself, so set hasCode to false. -->
-    <application android:label="@string/app_name"
-                 android:hasCode="false"
-                 android:allowBackup="false">
-        <!-- Our activity is the built-in NativeActivity framework class.
-             This will take care of integrating with our NDK code. -->
-        <activity android:name="android.app.NativeActivity"
-                android:label="@string/app_name"
-                android:configChanges="orientation|keyboardHidden"
-                android:screenOrientation="landscape">
-            <!-- Tell NativeActivity the name of or .so -->
-            <meta-data android:name="android.app.lib_name"
-                    android:value="FlatBufferSample" />
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-
-</manifest>
-<!-- END_INCLUDE(manifest) -->
diff --git a/samples/android/build.gradle b/samples/android/build.gradle
deleted file mode 100644
index 81c1af0..0000000
--- a/samples/android/build.gradle
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2017 Google, Inc.
-//
-// This software is provided 'as-is', without any express or implied
-// warranty.  In no event will the authors be held liable for any damages
-// arising from the use of this software.
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-// 1. The origin of this software must not be misrepresented; you must not
-// claim that you wrote the original software. If you use this software
-// in a product, an acknowledgment in the product documentation would be
-// appreciated but is not required.
-// 2. Altered source versions must be plainly marked as such, and must not be
-// misrepresented as being the original software.
-// 3. This notice may not be removed or altered from any source distribution.
-
-buildscript {
-  repositories {
-    jcenter()
-  }
-  dependencies {
-    classpath 'com.android.tools.build:gradle:2.3.0'
-  }
-}
-
-allprojects {
-  repositories {
-    jcenter()
-  }
-}
-
-apply plugin: 'com.android.application'
-
-android {
-  compileSdkVersion 25
-  buildToolsVersion '25.0.2'
-
-  sourceSets {
-    main {
-      manifest.srcFile 'AndroidManifest.xml'
-      res.srcDirs = ['res']
-    }
-  }
-
-  externalNativeBuild {
-    ndkBuild {
-      path "jni/Android.mk"
-    }
-  }
-
-  defaultConfig {
-    applicationId 'com.samples.FlatBufferSample'
-    // This is the platform API where NativeActivity was introduced.
-    minSdkVersion 9
-    targetSdkVersion 25
-    versionCode 1
-    versionName "1.0"
-
-    buildTypes {
-      release {
-        minifyEnabled false
-      }
-    }
-
-    externalNativeBuild {
-      ndkBuild {
-        targets "FlatBufferSample"
-        arguments "-j" + Runtime.getRuntime().availableProcessors()
-        abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
-      }
-    }
-  }
-
-  lintOptions {
-    abortOnError false
-  }
-
-  // Build with each STL variant.
-  productFlavors {
-    stlport {
-      applicationIdSuffix ".stlport"
-      versionNameSuffix "-stlport"
-      externalNativeBuild {
-        ndkBuild {
-          arguments "APP_STL=stlport_static"
-        }
-      }
-    }
-    gnustl {
-      applicationIdSuffix ".gnustl"
-      versionNameSuffix "-gnustl"
-      externalNativeBuild {
-        ndkBuild {
-          arguments "APP_STL=gnustl_static"
-        }
-      }
-    }
-    libcpp {
-      applicationIdSuffix ".libcpp"
-      versionNameSuffix "-libcpp"
-      externalNativeBuild {
-        ndkBuild {
-          arguments "APP_STL=c++_static"
-        }
-      }
-    }
-  }
-}
diff --git a/samples/android/gradle/wrapper/gradle-wrapper.jar b/samples/android/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index b4163b8..0000000
--- a/samples/android/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/samples/android/gradle/wrapper/gradle-wrapper.properties b/samples/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 1e1168c..0000000
--- a/samples/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Mon Jun 19 11:54:59 PDT 2017
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
diff --git a/samples/android/gradlew b/samples/android/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/samples/android/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-##  Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
-    echo "$*"
-}
-
-die () {
-    echo
-    echo "$*"
-    echo
-    exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-  NONSTOP* )
-    nonstop=true
-    ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-        # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
-    else
-        JAVACMD="$JAVA_HOME/bin/java"
-    fi
-    if [ ! -x "$JAVACMD" ] ; then
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-    fi
-else
-    JAVACMD="java"
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-    JAVACMD=`cygpath --unix "$JAVACMD"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
-        fi
-        i=$((i+1))
-    done
-    case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
-    esac
-fi
-
-# Escape application args
-save () {
-    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
-    echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
-  cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/samples/android/gradlew.bat b/samples/android/gradlew.bat
deleted file mode 100644
index f955316..0000000
--- a/samples/android/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem  Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/samples/android/jni/Android.mk b/samples/android/jni/Android.mk
deleted file mode 100644
index 917c2f9..0000000
--- a/samples/android/jni/Android.mk
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2013 Google, Inc.
-#
-# This software is provided 'as-is', without any express or implied
-# warranty.  In no event will the authors be held liable for any damages
-# arising from the use of this software.
-# Permission is granted to anyone to use this software for any purpose,
-# including commercial applications, and to alter it and redistribute it
-# freely, subject to the following restrictions:
-# 1. The origin of this software must not be misrepresented; you must not
-# claim that you wrote the original software. If you use this software
-# in a product, an acknowledgment in the product documentation would be
-# appreciated but is not required.
-# 2. Altered source versions must be plainly marked as such, and must not be
-# misrepresented as being the original software.
-# 3. This notice may not be removed or altered from any source distribution.
-
-LOCAL_PATH := $(call my-dir)
-FLATBUFFERS_ROOT_DIR := $(LOCAL_PATH)/../../..
-
-# FlatBuffers test
-include $(CLEAR_VARS)
-
-# Include the FlatBuffer utility function to generate header files from schemas.
-include $(FLATBUFFERS_ROOT_DIR)/android/jni/include.mk
-
-LOCAL_MODULE := FlatBufferSample
-
-# Set up some useful variables to identify schema and output directories and
-# schema files.
-ANDROID_SAMPLE_GENERATED_OUTPUT_DIR := $(LOCAL_PATH)/gen/include
-ANDROID_SAMPLE_SCHEMA_DIR := $(LOCAL_PATH)/schemas
-ANDROID_SAMPLE_SCHEMA_FILES := $(ANDROID_SAMPLE_SCHEMA_DIR)/animal.fbs
-
-LOCAL_C_INCLUDES := $(ANDROID_SAMPLE_GENERATED_OUTPUT_DIR)
-
-$(info $(LOCAL_C_INCLUDES))
-
-LOCAL_SRC_FILES := main.cpp
-
-LOCAL_CPPFLAGS := -std=c++11 -fexceptions -Wall -Wno-literal-suffix
-LOCAL_LDLIBS := -llog -landroid -latomic
-LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers
-
-ifeq (,$(ANDROID_SAMPLE_RUN_ONCE))
-ANDROID_SAMPLE_RUN_ONCE := 1
-$(call flatbuffers_header_build_rules,$(ANDROID_SAMPLE_SCHEMA_FILES),$(ANDROID_SAMPLE_SCHEMA_DIR),$(ANDROID_SAMPLE_GENERATED_OUTPUT_DIR),,$(LOCAL_SRC_FILES))
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Path to Flatbuffers root directory.
-$(call import-add-path,$(FLATBUFFERS_ROOT_DIR)/..)
-
-$(call import-module,flatbuffers/android/jni)
-$(call import-module,android/native_app_glue)
diff --git a/samples/android/jni/Application.mk b/samples/android/jni/Application.mk
deleted file mode 100644
index ca9e800..0000000
--- a/samples/android/jni/Application.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2014 Google, Inc.
-#
-# This software is provided 'as-is', without any express or implied
-# warranty.  In no event will the authors be held liable for any damages
-# arising from the use of this software.
-# Permission is granted to anyone to use this software for any purpose,
-# including commercial applications, and to alter it and redistribute it
-# freely, subject to the following restrictions:
-# 1. The origin of this software must not be misrepresented; you must not
-# claim that you wrote the original software. If you use this software
-# in a product, an acknowledgment in the product documentation would be
-# appreciated but is not required.
-# 2. Altered source versions must be plainly marked as such, and must not be
-# misrepresented as being the original software.
-# 3. This notice may not be removed or altered from any source distribution.
-APP_PLATFORM := android-9
-APP_PROJECT_PATH := $(call my-dir)/..
-APP_STL ?= stlport_static
-APP_ABI := armeabi-v7a
-APP_CPPFLAGS += -std=c++11
diff --git a/samples/android/jni/main.cpp b/samples/android/jni/main.cpp
deleted file mode 100644
index 8758027..0000000
--- a/samples/android/jni/main.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2015 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// 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.
-
-#include <android/log.h>
-
-#include "android_native_app_glue.h"
-#include "animal_generated.h" // Includes "flatbuffers/flatbuffers.h".
-
-void android_main(android_app *app) {
-  app_dummy();
-
-  flatbuffers::FlatBufferBuilder builder;
-  auto name = builder.CreateString("Dog");
-  auto sound = builder.CreateString("Bark");
-  auto animal_buffer = sample::CreateAnimal(builder, name, sound);
-  builder.Finish(animal_buffer);
-
-  // We now have a FlatBuffer that can be stored on disk or sent over a network.
-
-  // ...Code to store on disk or send over a network goes here...
-
-  // Instead, we're going to access it immediately, as if we just recieved this.
-
-  auto animal = sample::GetAnimal(builder.GetBufferPointer());
-
-  assert(animal->name()->str() == "Dog");
-  assert(animal->sound()->str() == "Bark");
-  (void)animal; // To silence "Unused Variable" warnings.
-
-  __android_log_print(ANDROID_LOG_INFO, "FlatBufferSample",
-      "FlatBuffer successfully created and verified.");
-}
diff --git a/samples/android/jni/schemas/animal.fbs b/samples/android/jni/schemas/animal.fbs
deleted file mode 100644
index d1bd38d..0000000
--- a/samples/android/jni/schemas/animal.fbs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// 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.
-
-namespace sample;
-
-table Animal {
-  name:string;
-  sound:string;
-}
-
-root_type Animal;
diff --git a/samples/android/res/values/strings.xml b/samples/android/res/values/strings.xml
deleted file mode 100644
index 57ddaf4..0000000
--- a/samples/android/res/values/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (c) 2015 Google, Inc.
-
-     This software is provided 'as-is', without any express or implied
-     warranty.  In no event will the authors be held liable for any damages
-     arising from the use of this software.
-     Permission is granted to anyone to use this software for any purpose,
-     including commercial applications, and to alter it and redistribute it
-     freely, subject to the following restrictions:
-     1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-     2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-     3. This notice may not be removed or altered from any source distribution.
- -->
-<resources>
-    <string name="app_name">FlatBufferSample</string>
-</resources>
diff --git a/samples/android_sample.sh b/samples/android_sample.sh
deleted file mode 100755
index 53633ac..0000000
--- a/samples/android_sample.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2015 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# 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.
-#
-# Note: This script requires the Android NDK and Android SDK to be installed.
-#       It also requires an Android device to be connected for installing and
-#       running the applicaton.
-
-sampledir=$(readlink -fn `dirname $0`)
-currentdir=$(readlink -fn `pwd`)
-
-if [[ "$sampledir" != "$currentdir" ]]; then
-  echo Error: This script must be run from inside the $sampledir directory.
-  echo You executed it from the $currentdir directory.
-  exit 1
-fi
-
-# Execute `build_apk.sh` to build and run the android app.
-cd android
-./gradlew build
-
-
-
diff --git a/samples/kotlin_sample.sh b/samples/kotlin_sample.sh
index 30ca00a..ca4ea86 100755
--- a/samples/kotlin_sample.sh
+++ b/samples/kotlin_sample.sh
@@ -56,5 +56,5 @@
 kotlin -cp ${sampledir}/kotlin/kotlin_sample.jar SampleBinary
 
 # Cleanup temporary files.
-# rm -rf MyGame/
+rm -rf MyGame/
 # rm -rf ${sampledir}/kotlin
diff --git a/samples/monster.bfbs b/samples/monster.bfbs
index 061a17b..7e1790c 100644
--- a/samples/monster.bfbs
+++ b/samples/monster.bfbs
Binary files differ
diff --git a/samples/monster_generated.h b/samples/monster_generated.h
index 30115da..8afde1e 100644
--- a/samples/monster_generated.h
+++ b/samples/monster_generated.h
@@ -12,9 +12,11 @@
 struct Vec3;
 
 struct Monster;
+struct MonsterBuilder;
 struct MonsterT;
 
 struct Weapon;
+struct WeaponBuilder;
 struct WeaponT;
 
 bool operator==(const Vec3 &lhs, const Vec3 &rhs);
@@ -58,7 +60,7 @@
 }
 
 inline const char *EnumNameColor(Color e) {
-  if (e < Color_Red || e > Color_Blue) return "";
+  if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
   const size_t index = static_cast<size_t>(e);
   return EnumNamesColor()[index];
 }
@@ -88,7 +90,7 @@
 }
 
 inline const char *EnumNameEquipment(Equipment e) {
-  if (e < Equipment_NONE || e > Equipment_Weapon) return "";
+  if (flatbuffers::IsOutRange(e, Equipment_NONE, Equipment_Weapon)) return "";
   const size_t index = static_cast<size_t>(e);
   return EnumNamesEquipment()[index];
 }
@@ -109,8 +111,8 @@
   EquipmentUnion(EquipmentUnion&& u) FLATBUFFERS_NOEXCEPT :
     type(Equipment_NONE), value(nullptr)
     { std::swap(type, u.type); std::swap(value, u.value); }
-  EquipmentUnion(const EquipmentUnion &) FLATBUFFERS_NOEXCEPT;
-  EquipmentUnion &operator=(const EquipmentUnion &u) FLATBUFFERS_NOEXCEPT
+  EquipmentUnion(const EquipmentUnion &);
+  EquipmentUnion &operator=(const EquipmentUnion &u)
     { EquipmentUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
   EquipmentUnion &operator=(EquipmentUnion &&u) FLATBUFFERS_NOEXCEPT
     { std::swap(type, u.type); std::swap(value, u.value); return *this; }
@@ -177,8 +179,10 @@
   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
     return Vec3TypeTable();
   }
-  Vec3() {
-    memset(static_cast<void *>(this), 0, sizeof(Vec3));
+  Vec3()
+      : x_(0),
+        y_(0),
+        z_(0) {
   }
   Vec3(float _x, float _y, float _z)
       : x_(flatbuffers::EndianScalar(_x)),
@@ -227,7 +231,7 @@
   std::vector<uint8_t> inventory;
   MyGame::Sample::Color color;
   std::vector<flatbuffers::unique_ptr<MyGame::Sample::WeaponT>> weapons;
-  EquipmentUnion equipped;
+  MyGame::Sample::EquipmentUnion equipped;
   std::vector<MyGame::Sample::Vec3> path;
   MonsterT()
       : mana(150),
@@ -256,6 +260,7 @@
 
 struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
   typedef MonsterT NativeTableType;
+  typedef MonsterBuilder Builder;
   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
     return MonsterTypeTable();
   }
@@ -316,9 +321,6 @@
   MyGame::Sample::Equipment equipped_type() const {
     return static_cast<MyGame::Sample::Equipment>(GetField<uint8_t>(VT_EQUIPPED_TYPE, 0));
   }
-  bool mutate_equipped_type(MyGame::Sample::Equipment _equipped_type) {
-    return SetField<uint8_t>(VT_EQUIPPED_TYPE, static_cast<uint8_t>(_equipped_type), 0);
-  }
   const void *equipped() const {
     return GetPointer<const void *>(VT_EQUIPPED);
   }
@@ -365,6 +367,7 @@
 }
 
 struct MonsterBuilder {
+  typedef Monster Table;
   flatbuffers::FlatBufferBuilder &fbb_;
   flatbuffers::uoffset_t start_;
   void add_pos(const MyGame::Sample::Vec3 *pos) {
@@ -401,7 +404,6 @@
         : fbb_(_fbb) {
     start_ = fbb_.StartTable();
   }
-  MonsterBuilder &operator=(const MonsterBuilder &);
   flatbuffers::Offset<Monster> Finish() {
     const auto end = fbb_.EndTable(start_);
     auto o = flatbuffers::Offset<Monster>(end);
@@ -489,6 +491,7 @@
 
 struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
   typedef WeaponT NativeTableType;
+  typedef WeaponBuilder Builder;
   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
     return WeaponTypeTable();
   }
@@ -521,6 +524,7 @@
 };
 
 struct WeaponBuilder {
+  typedef Weapon Table;
   flatbuffers::FlatBufferBuilder &fbb_;
   flatbuffers::uoffset_t start_;
   void add_name(flatbuffers::Offset<flatbuffers::String> name) {
@@ -533,7 +537,6 @@
         : fbb_(_fbb) {
     start_ = fbb_.StartTable();
   }
-  WeaponBuilder &operator=(const WeaponBuilder &);
   flatbuffers::Offset<Weapon> Finish() {
     const auto end = fbb_.EndTable(start_);
     auto o = flatbuffers::Offset<Weapon>(end);
@@ -565,24 +568,24 @@
 flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
 
 inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
-  auto _o = new MonsterT();
-  UnPackTo(_o, _resolver);
-  return _o;
+  flatbuffers::unique_ptr<MyGame::Sample::MonsterT> _o = flatbuffers::unique_ptr<MyGame::Sample::MonsterT>(new MonsterT());
+  UnPackTo(_o.get(), _resolver);
+  return _o.release();
 }
 
 inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
   (void)_o;
   (void)_resolver;
-  { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Sample::Vec3>(new MyGame::Sample::Vec3(*_e)); };
-  { auto _e = mana(); _o->mana = _e; };
-  { auto _e = hp(); _o->hp = _e; };
-  { auto _e = name(); if (_e) _o->name = _e->str(); };
-  { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inventory[_i] = _e->Get(_i); } } };
-  { auto _e = color(); _o->color = _e; };
-  { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); } } };
-  { auto _e = equipped_type(); _o->equipped.type = _e; };
-  { auto _e = equipped(); if (_e) _o->equipped.value = EquipmentUnion::UnPack(_e, equipped_type(), _resolver); };
-  { auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } };
+  { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Sample::Vec3>(new MyGame::Sample::Vec3(*_e)); }
+  { auto _e = mana(); _o->mana = _e; }
+  { auto _e = hp(); _o->hp = _e; }
+  { auto _e = name(); if (_e) _o->name = _e->str(); }
+  { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
+  { auto _e = color(); _o->color = _e; }
+  { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); } } }
+  { auto _e = equipped_type(); _o->equipped.type = _e; }
+  { auto _e = equipped(); if (_e) _o->equipped.value = MyGame::Sample::EquipmentUnion::UnPack(_e, equipped_type(), _resolver); }
+  { auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } }
 }
 
 inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -618,16 +621,16 @@
 }
 
 inline WeaponT *Weapon::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
-  auto _o = new WeaponT();
-  UnPackTo(_o, _resolver);
-  return _o;
+  flatbuffers::unique_ptr<MyGame::Sample::WeaponT> _o = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(new WeaponT());
+  UnPackTo(_o.get(), _resolver);
+  return _o.release();
 }
 
 inline void Weapon::UnPackTo(WeaponT *_o, const flatbuffers::resolver_function_t *_resolver) const {
   (void)_o;
   (void)_resolver;
-  { auto _e = name(); if (_e) _o->name = _e->str(); };
-  { auto _e = damage(); _o->damage = _e; };
+  { auto _e = name(); if (_e) _o->name = _e->str(); }
+  { auto _e = damage(); _o->damage = _e; }
 }
 
 inline flatbuffers::Offset<Weapon> Weapon::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -655,7 +658,7 @@
       auto ptr = reinterpret_cast<const MyGame::Sample::Weapon *>(obj);
       return verifier.VerifyTable(ptr);
     }
-    default: return false;
+    default: return true;
   }
 }
 
@@ -691,7 +694,7 @@
   }
 }
 
-inline EquipmentUnion::EquipmentUnion(const EquipmentUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) {
+inline EquipmentUnion::EquipmentUnion(const EquipmentUnion &u) : type(u.type), value(nullptr) {
   switch (type) {
     case Equipment_Weapon: {
       value = new MyGame::Sample::WeaponT(*reinterpret_cast<MyGame::Sample::WeaponT *>(u.value));
@@ -730,7 +733,7 @@
     "Blue"
   };
   static const flatbuffers::TypeTable tt = {
-    flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names
+    flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
   };
   return &tt;
 }
@@ -748,7 +751,7 @@
     "Weapon"
   };
   static const flatbuffers::TypeTable tt = {
-    flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, names
+    flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, nullptr, names
   };
   return &tt;
 }
@@ -766,7 +769,7 @@
     "z"
   };
   static const flatbuffers::TypeTable tt = {
-    flatbuffers::ST_STRUCT, 3, type_codes, nullptr, values, names
+    flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
   };
   return &tt;
 }
@@ -805,7 +808,7 @@
     "path"
   };
   static const flatbuffers::TypeTable tt = {
-    flatbuffers::ST_TABLE, 11, type_codes, type_refs, nullptr, names
+    flatbuffers::ST_TABLE, 11, type_codes, type_refs, nullptr, nullptr, names
   };
   return &tt;
 }
@@ -820,7 +823,7 @@
     "damage"
   };
   static const flatbuffers::TypeTable tt = {
-    flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, names
+    flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, nullptr, names
   };
   return &tt;
 }
diff --git a/samples/monster_generated.rs b/samples/monster_generated.rs
index 9ec573c..e352b75 100644
--- a/samples/monster_generated.rs
+++ b/samples/monster_generated.rs
@@ -1,59 +1,83 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
 
+#![allow(unused_imports, dead_code)]
+
+use std::mem;
+use std::cmp::Ordering;
+
+extern crate flatbuffers;
+use self::flatbuffers::EndianScalar;
+
+#[allow(unused_imports, dead_code)]
 pub mod my_game {
-  #![allow(dead_code)]
-  #![allow(unused_imports)]
 
   use std::mem;
-  use std::marker::PhantomData;
   use std::cmp::Ordering;
 
   extern crate flatbuffers;
   use self::flatbuffers::EndianScalar;
+#[allow(unused_imports, dead_code)]
 pub mod sample {
-  #![allow(dead_code)]
-  #![allow(unused_imports)]
 
   use std::mem;
-  use std::marker::PhantomData;
   use std::cmp::Ordering;
 
   extern crate flatbuffers;
   use self::flatbuffers::EndianScalar;
 
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_COLOR: i8 = 0;
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_COLOR: i8 = 2;
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
 #[allow(non_camel_case_types)]
-#[repr(i8)]
-#[derive(Clone, Copy, PartialEq, Debug)]
-pub enum Color {
-  Red = 0,
-  Green = 1,
-  Blue = 2
+pub const ENUM_VALUES_COLOR: [Color; 3] = [
+  Color::Red,
+  Color::Green,
+  Color::Blue,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[repr(transparent)]
+pub struct Color(pub i8);
+#[allow(non_upper_case_globals)]
+impl Color {
+  pub const Red: Self = Self(0);
+  pub const Green: Self = Self(1);
+  pub const Blue: Self = Self(2);
+
+  pub const ENUM_MIN: i8 = 0;
+  pub const ENUM_MAX: i8 = 2;
+  pub const ENUM_VALUES: &'static [Self] = &[
+    Self::Red,
+    Self::Green,
+    Self::Blue,
+  ];
+  /// Returns the variant's name or "" if unknown.
+  pub fn variant_name(self) -> Option<&'static str> {
+    match self {
+      Self::Red => Some("Red"),
+      Self::Green => Some("Green"),
+      Self::Blue => Some("Blue"),
+      _ => None,
+    }
+  }
 }
-
-const ENUM_MIN_COLOR: i8 = 0;
-const ENUM_MAX_COLOR: i8 = 2;
-
+impl std::fmt::Debug for Color {
+  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+    if let Some(name) = self.variant_name() {
+      f.write_str(name)
+    } else {
+      f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+    }
+  }
+}
 impl<'a> flatbuffers::Follow<'a> for Color {
   type Inner = Self;
   #[inline]
   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
-    flatbuffers::read_scalar_at::<Self>(buf, loc)
-  }
-}
-
-impl flatbuffers::EndianScalar for Color {
-  #[inline]
-  fn to_little_endian(self) -> Self {
-    let n = i8::to_le(self as i8);
-    let p = &n as *const i8 as *const Color;
-    unsafe { *p }
-  }
-  #[inline]
-  fn from_little_endian(self) -> Self {
-    let n = i8::from_le(self as i8);
-    let p = &n as *const i8 as *const Color;
-    unsafe { *p }
+    Self(flatbuffers::read_scalar_at::<i8>(buf, loc))
   }
 }
 
@@ -61,60 +85,69 @@
     type Output = Color;
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
-        flatbuffers::emplace_scalar::<Color>(dst, *self);
+        flatbuffers::emplace_scalar::<i8>(dst, self.0);
     }
 }
 
-#[allow(non_camel_case_types)]
-const ENUM_VALUES_COLOR:[Color; 3] = [
-  Color::Red,
-  Color::Green,
-  Color::Blue
-];
-
-#[allow(non_camel_case_types)]
-const ENUM_NAMES_COLOR:[&'static str; 3] = [
-    "Red",
-    "Green",
-    "Blue"
-];
-
-pub fn enum_name_color(e: Color) -> &'static str {
-  let index: usize = e as usize;
-  ENUM_NAMES_COLOR[index]
+impl flatbuffers::EndianScalar for Color {
+  #[inline]
+  fn to_little_endian(self) -> Self {
+    Self(i8::to_le(self.0))
+  }
+  #[inline]
+  fn from_little_endian(self) -> Self {
+    Self(i8::from_le(self.0))
+  }
 }
 
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_EQUIPMENT: u8 = 0;
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_EQUIPMENT: u8 = 1;
+#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
 #[allow(non_camel_case_types)]
-#[repr(u8)]
-#[derive(Clone, Copy, PartialEq, Debug)]
-pub enum Equipment {
-  NONE = 0,
-  Weapon = 1
+pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
+  Equipment::NONE,
+  Equipment::Weapon,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[repr(transparent)]
+pub struct Equipment(pub u8);
+#[allow(non_upper_case_globals)]
+impl Equipment {
+  pub const NONE: Self = Self(0);
+  pub const Weapon: Self = Self(1);
+
+  pub const ENUM_MIN: u8 = 0;
+  pub const ENUM_MAX: u8 = 1;
+  pub const ENUM_VALUES: &'static [Self] = &[
+    Self::NONE,
+    Self::Weapon,
+  ];
+  /// Returns the variant's name or "" if unknown.
+  pub fn variant_name(self) -> Option<&'static str> {
+    match self {
+      Self::NONE => Some("NONE"),
+      Self::Weapon => Some("Weapon"),
+      _ => None,
+    }
+  }
 }
-
-const ENUM_MIN_EQUIPMENT: u8 = 0;
-const ENUM_MAX_EQUIPMENT: u8 = 1;
-
+impl std::fmt::Debug for Equipment {
+  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+    if let Some(name) = self.variant_name() {
+      f.write_str(name)
+    } else {
+      f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+    }
+  }
+}
 impl<'a> flatbuffers::Follow<'a> for Equipment {
   type Inner = Self;
   #[inline]
   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
-    flatbuffers::read_scalar_at::<Self>(buf, loc)
-  }
-}
-
-impl flatbuffers::EndianScalar for Equipment {
-  #[inline]
-  fn to_little_endian(self) -> Self {
-    let n = u8::to_le(self as u8);
-    let p = &n as *const u8 as *const Equipment;
-    unsafe { *p }
-  }
-  #[inline]
-  fn from_little_endian(self) -> Self {
-    let n = u8::from_le(self as u8);
-    let p = &n as *const u8 as *const Equipment;
-    unsafe { *p }
+    Self(flatbuffers::read_scalar_at::<u8>(buf, loc))
   }
 }
 
@@ -122,43 +155,46 @@
     type Output = Equipment;
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
-        flatbuffers::emplace_scalar::<Equipment>(dst, *self);
+        flatbuffers::emplace_scalar::<u8>(dst, self.0);
     }
 }
 
-#[allow(non_camel_case_types)]
-const ENUM_VALUES_EQUIPMENT:[Equipment; 2] = [
-  Equipment::NONE,
-  Equipment::Weapon
-];
-
-#[allow(non_camel_case_types)]
-const ENUM_NAMES_EQUIPMENT:[&'static str; 2] = [
-    "NONE",
-    "Weapon"
-];
-
-pub fn enum_name_equipment(e: Equipment) -> &'static str {
-  let index: usize = e as usize;
-  ENUM_NAMES_EQUIPMENT[index]
+impl flatbuffers::EndianScalar for Equipment {
+  #[inline]
+  fn to_little_endian(self) -> Self {
+    Self(u8::to_le(self.0))
+  }
+  #[inline]
+  fn from_little_endian(self) -> Self {
+    Self(u8::from_le(self.0))
+  }
 }
 
 pub struct EquipmentUnionTableOffset {}
 // struct Vec3, aligned to 4
 #[repr(C, align(4))]
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, PartialEq)]
 pub struct Vec3 {
   x_: f32,
   y_: f32,
   z_: f32,
 } // pub struct Vec3
+impl std::fmt::Debug for Vec3 {
+  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+    f.debug_struct("Vec3")
+      .field("x", &self.x())
+      .field("y", &self.y())
+      .field("z", &self.z())
+      .finish()
+  }
+}
+
 impl flatbuffers::SafeSliceAccess for Vec3 {}
 impl<'a> flatbuffers::Follow<'a> for Vec3 {
   type Inner = &'a Vec3;
   #[inline]
   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
     <&'a Vec3>::follow(buf, loc)
-    //flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
   }
 }
 impl<'a> flatbuffers::Follow<'a> for &'a Vec3 {
@@ -192,7 +228,7 @@
 
 
 impl Vec3 {
-  pub fn new<'a>(_x: f32, _y: f32, _z: f32) -> Self {
+  pub fn new(_x: f32, _y: f32, _z: f32) -> Self {
     Vec3 {
       x_: _x.to_little_endian(),
       y_: _y.to_little_endian(),
@@ -200,19 +236,19 @@
 
     }
   }
-  pub fn x<'a>(&'a self) -> f32 {
+  pub fn x(&self) -> f32 {
     self.x_.from_little_endian()
   }
-  pub fn y<'a>(&'a self) -> f32 {
+  pub fn y(&self) -> f32 {
     self.y_.from_little_endian()
   }
-  pub fn z<'a>(&'a self) -> f32 {
+  pub fn z(&self) -> f32 {
     self.z_.from_little_endian()
   }
 }
 
 pub enum MonsterOffset {}
-#[derive(Copy, Clone, Debug, PartialEq)]
+#[derive(Copy, Clone, PartialEq)]
 
 pub struct Monster<'a> {
   pub _tab: flatbuffers::Table<'a>,
@@ -222,9 +258,7 @@
     type Inner = Monster<'a>;
     #[inline]
     fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
-        Self {
-            _tab: flatbuffers::Table { buf: buf, loc: loc },
-        }
+        Self { _tab: flatbuffers::Table { buf, loc } }
     }
 }
 
@@ -240,6 +274,7 @@
         _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
         args: &'args MonsterArgs<'args>) -> flatbuffers::WIPOffset<Monster<'bldr>> {
       let mut builder = MonsterBuilder::new(_fbb);
+      if let Some(x) = args.path { builder.add_path(x); }
       if let Some(x) = args.equipped { builder.add_equipped(x); }
       if let Some(x) = args.weapons { builder.add_weapons(x); }
       if let Some(x) = args.inventory { builder.add_inventory(x); }
@@ -261,48 +296,53 @@
     pub const VT_WEAPONS: flatbuffers::VOffsetT = 18;
     pub const VT_EQUIPPED_TYPE: flatbuffers::VOffsetT = 20;
     pub const VT_EQUIPPED: flatbuffers::VOffsetT = 22;
+    pub const VT_PATH: flatbuffers::VOffsetT = 24;
 
   #[inline]
-  pub fn pos(&'a self) -> Option<&'a Vec3> {
+  pub fn pos(&self) -> Option<&'a Vec3> {
     self._tab.get::<Vec3>(Monster::VT_POS, None)
   }
   #[inline]
-  pub fn mana(&'a self) -> i16 {
+  pub fn mana(&self) -> i16 {
     self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()
   }
   #[inline]
-  pub fn hp(&'a self) -> i16 {
+  pub fn hp(&self) -> i16 {
     self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()
   }
   #[inline]
-  pub fn name(&'a self) -> Option<&'a str> {
+  pub fn name(&self) -> Option<&'a str> {
     self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)
   }
   #[inline]
-  pub fn inventory(&'a self) -> Option<&'a [u8]> {
+  pub fn inventory(&self) -> Option<&'a [u8]> {
     self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None).map(|v| v.safe_slice())
   }
   #[inline]
-  pub fn color(&'a self) -> Color {
+  pub fn color(&self) -> Color {
     self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()
   }
   #[inline]
-  pub fn weapons(&'a self) -> Option<flatbuffers::Vector<flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
+  pub fn weapons(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
     self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<Weapon<'a>>>>>(Monster::VT_WEAPONS, None)
   }
   #[inline]
-  pub fn equipped_type(&'a self) -> Equipment {
+  pub fn equipped_type(&self) -> Equipment {
     self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()
   }
   #[inline]
-  pub fn equipped(&'a self) -> Option<flatbuffers::Table<'a>> {
+  pub fn equipped(&self) -> Option<flatbuffers::Table<'a>> {
     self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)
   }
   #[inline]
+  pub fn path(&self) -> Option<&'a [Vec3]> {
+    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Vec3>>>(Monster::VT_PATH, None).map(|v| v.safe_slice() )
+  }
+  #[inline]
   #[allow(non_snake_case)]
-  pub fn equipped_as_weapon(&'a self) -> Option<Weapon> {
+  pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
     if self.equipped_type() == Equipment::Weapon {
-      self.equipped().map(|u| Weapon::init_from_table(u))
+      self.equipped().map(Weapon::init_from_table)
     } else {
       None
     }
@@ -311,15 +351,16 @@
 }
 
 pub struct MonsterArgs<'a> {
-    pub pos: Option<&'a  Vec3>,
+    pub pos: Option<&'a Vec3>,
     pub mana: i16,
     pub hp: i16,
-    pub name: Option<flatbuffers::WIPOffset<&'a  str>>,
-    pub inventory: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a ,  u8>>>,
+    pub name: Option<flatbuffers::WIPOffset<&'a str>>,
+    pub inventory: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
     pub color: Color,
-    pub weapons: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<Weapon<'a >>>>>,
+    pub weapons: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>>>,
     pub equipped_type: Equipment,
     pub equipped: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
+    pub path: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Vec3>>>,
 }
 impl<'a> Default for MonsterArgs<'a> {
     #[inline]
@@ -334,6 +375,7 @@
             weapons: None,
             equipped_type: Equipment::NONE,
             equipped: None,
+            path: None,
         }
     }
 }
@@ -343,7 +385,7 @@
 }
 impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
   #[inline]
-  pub fn add_pos(&mut self, pos: &'b  Vec3) {
+  pub fn add_pos(&mut self, pos: &Vec3) {
     self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
   }
   #[inline]
@@ -379,6 +421,10 @@
     self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
   }
   #[inline]
+  pub fn add_path(&mut self, path: flatbuffers::WIPOffset<flatbuffers::Vector<'b , Vec3>>) {
+    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
+  }
+  #[inline]
   pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MonsterBuilder<'a, 'b> {
     let start = _fbb.start_table();
     MonsterBuilder {
@@ -393,8 +439,36 @@
   }
 }
 
+impl std::fmt::Debug for Monster<'_> {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    let mut ds = f.debug_struct("Monster");
+      ds.field("pos", &self.pos());
+      ds.field("mana", &self.mana());
+      ds.field("hp", &self.hp());
+      ds.field("name", &self.name());
+      ds.field("inventory", &self.inventory());
+      ds.field("color", &self.color());
+      ds.field("weapons", &self.weapons());
+      ds.field("equipped_type", &self.equipped_type());
+      match self.equipped_type() {
+        Equipment::Weapon => {
+          if let Some(x) = self.equipped_as_weapon() {
+            ds.field("equipped", &x)
+          } else {
+            ds.field("equipped", &"InvalidFlatbuffer: Union discriminant does not match value.")
+          }
+        },
+        _ => { 
+          let x: Option<()> = None;
+          ds.field("equipped", &x)
+        },
+      };
+      ds.field("path", &self.path());
+      ds.finish()
+  }
+}
 pub enum WeaponOffset {}
-#[derive(Copy, Clone, Debug, PartialEq)]
+#[derive(Copy, Clone, PartialEq)]
 
 pub struct Weapon<'a> {
   pub _tab: flatbuffers::Table<'a>,
@@ -404,9 +478,7 @@
     type Inner = Weapon<'a>;
     #[inline]
     fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
-        Self {
-            _tab: flatbuffers::Table { buf: buf, loc: loc },
-        }
+        Self { _tab: flatbuffers::Table { buf, loc } }
     }
 }
 
@@ -431,17 +503,17 @@
     pub const VT_DAMAGE: flatbuffers::VOffsetT = 6;
 
   #[inline]
-  pub fn name(&'a self) -> Option<&'a str> {
+  pub fn name(&self) -> Option<&'a str> {
     self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)
   }
   #[inline]
-  pub fn damage(&'a self) -> i16 {
+  pub fn damage(&self) -> i16 {
     self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()
   }
 }
 
 pub struct WeaponArgs<'a> {
-    pub name: Option<flatbuffers::WIPOffset<&'a  str>>,
+    pub name: Option<flatbuffers::WIPOffset<&'a str>>,
     pub damage: i16,
 }
 impl<'a> Default for WeaponArgs<'a> {
@@ -481,6 +553,14 @@
   }
 }
 
+impl std::fmt::Debug for Weapon<'_> {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    let mut ds = f.debug_struct("Weapon");
+      ds.field("name", &self.name());
+      ds.field("damage", &self.damage());
+      ds.finish()
+  }
+}
 #[inline]
 pub fn get_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
   flatbuffers::get_root::<Monster<'a>>(buf)
diff --git a/samples/monsterdata.json b/samples/monsterdata.json
index fa60b35..b1e7090 100644
--- a/samples/monsterdata.json
+++ b/samples/monsterdata.json
@@ -1,24 +1,24 @@
 {
-  pos: {
-    x: 1.0,
-    y: 2.0,
-    z: 3.0
+  "pos": {
+    "x": 1.0,
+    "y": 2.0,
+    "z": 3.0
   },
-  hp: 300,
-  name: "Orc",
-  weapons: [
+  "hp": 300,
+  "name": "Orc",
+  "weapons": [
     {
-      name: "axe",
-      damage: 100
+      "name": "axe",
+      "damage": 100
     },
     {
-      name: "bow",
-      damage: 90
+      "name": "bow",
+      "damage": 90
     }
   ],
-  equipped_type: "Weapon",
-  equipped: {
-    name: "bow",
-    damage: 90
+  "equipped_type": "Weapon",
+  "equipped": {
+    "name": "bow",
+    "damage": 90
   }
 }
diff --git a/samples/sample_bfbs.cpp b/samples/sample_bfbs.cpp
index 9512e24..0e17690 100644
--- a/samples/sample_bfbs.cpp
+++ b/samples/sample_bfbs.cpp
@@ -16,9 +16,7 @@
 
 #include "flatbuffers/idl.h"
 #include "flatbuffers/util.h"
-
-#include "monster_test_generated.h"
-#include "monster_generated.h" // Already includes "flatbuffers/flatbuffers.h".
+#include "monster_generated.h"  // Already includes "flatbuffers/flatbuffers.h".
 
 using namespace MyGame::Sample;
 
@@ -31,7 +29,8 @@
   std::string bfbs_file;
   bool ok =
       flatbuffers::LoadFile("tests/monster_test.fbs", false, &schema_file) &&
-      flatbuffers::LoadFile("tests/monsterdata_test.golden", false, &json_file) &&
+      flatbuffers::LoadFile("tests/monsterdata_test.golden", false,
+                            &json_file) &&
       flatbuffers::LoadFile("tests/monster_test.bfbs", true, &bfbs_file);
   if (!ok) {
     printf("couldn't load files!\n");
diff --git a/samples/sample_binary.cpp b/samples/sample_binary.cpp
index 46f08bb..b8f4f1f 100644
--- a/samples/sample_binary.cpp
+++ b/samples/sample_binary.cpp
@@ -20,7 +20,7 @@
 
 // Example how to use FlatBuffers to create and read binary buffers.
 
-int main(int /*argc*/, const char * /*argv*/ []) {
+int main(int /*argc*/, const char * /*argv*/[]) {
   // Build up a serialized buffer algorithmically:
   flatbuffers::FlatBufferBuilder builder;
 
diff --git a/samples/sample_binary.rs b/samples/sample_binary.rs
index 7a4c2ae..6fb987e 100644
--- a/samples/sample_binary.rs
+++ b/samples/sample_binary.rs
@@ -152,4 +152,11 @@
   //assert_eq!(monster.path().unwrap()[1].x(), 4.0);
 
   println!("The FlatBuffer was successfully created and accessed!");
+  dbg!(monster);
+}
+
+#[cfg(test)]
+#[test]
+fn test_main() {
+    main()
 }
diff --git a/samples/sample_binary.swift b/samples/sample_binary.swift
new file mode 100644
index 0000000..832eb3d
--- /dev/null
+++ b/samples/sample_binary.swift
@@ -0,0 +1,67 @@
+ // THIS IS JUST TO SHOW THE CODE, PLEASE DO IMPORT FLATBUFFERS WITH SPM..
+import FlatBuffers
+
+typealias Monster = MyGame.Sample.Monster
+typealias Weapon = MyGame.Sample.Weapon
+typealias Color = MyGame.Sample.Color
+typealias Vec3 = MyGame.Sample.Vec3
+
+func main() {
+    let expectedDMG: [Int16] = [3, 5]
+    let expectedNames = ["Sword", "Axe"]
+
+    var builder = FlatBufferBuilder(initialSize: 1024)
+    let weapon1Name = builder.create(string: expectedNames[0])
+    let weapon2Name = builder.create(string: expectedNames[1])
+        
+    let weapon1Start = Weapon.startWeapon(&builder)
+    Weapon.add(name: weapon1Name, &builder)
+    Weapon.add(damage: expectedDMG[0], &builder)
+    let sword = Weapon.endWeapon(&builder, start: weapon1Start)
+    let weapon2Start = Weapon.startWeapon(&builder)
+    Weapon.add(name: weapon2Name, &builder)
+    Weapon.add(damage: expectedDMG[1], &builder)
+    let axe = Weapon.endWeapon(&builder, start: weapon2Start)
+    
+    let name = builder.create(string: "Orc")
+    let inventory: [Byte] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+    let inventoryOffset = builder.createVector(inventory)
+
+    let weaponsOffset = builder.createVector(ofOffsets: [sword, axe])
+    let pos = MyGame.Sample.createVec3(x: 1, y: 2, z: 3)
+
+    let orc = Monster.createMonster(&builder,
+                                    structOfPos: pos,
+                                    hp: 300,
+                                    offsetOfName: name,
+                                    vectorOfInventory: inventoryOffset,
+                                    color: .red,
+                                    vectorOfWeapons: weaponsOffset,
+                                    equippedType: .weapon,
+                                    offsetOfEquipped: axe)
+    builder.finish(offset: orc)
+    
+    let buf = builder.sizedByteArray
+    let monster = Monster.getRootAsMonster(bb: ByteBuffer(bytes: buf))
+
+    assert(monster.mana == 150)
+    assert(monster.hp == 300)
+    assert(monster.name == "Orc")
+    assert(monster.color == MyGame.Sample.Color.red)
+    assert(monster.pos != nil)
+    for i in 0..<monster.inventoryCount {
+        assert(i == monster.inventory(at: i))
+    }
+        
+    for i in 0..<monster.weaponsCount {
+        let weap = monster.weapons(at: i)
+        let index = Int(i)
+        assert(weap?.damage == expectedDMG[index])
+        assert(weap?.name == expectedNames[index])
+    }
+    assert(monster.equippedType == .weapon)
+    let equipped = monster.equipped(type: Weapon.self)
+    assert(equipped?.name == "Axe")
+    assert(equipped?.damage == 5)
+    print("Monster Object is Verified")
+}
diff --git a/samples/sample_flexbuffers.rs b/samples/sample_flexbuffers.rs
new file mode 100644
index 0000000..efe02c3
--- /dev/null
+++ b/samples/sample_flexbuffers.rs
@@ -0,0 +1,184 @@
+// Copyright 2019 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://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.
+
+extern crate flexbuffers;
+
+use flexbuffers::{BitWidth, Builder, Reader, ReaderError};
+
+
+// In this Example we're creating a monster that corresponds to the following JSON:
+// {
+//     "coins": [5, 10, 25, 25, 25, 100],
+//     "color": [255, 0, 0, 255],
+//     "enraged": true,
+//     "hp": 80,
+//     "mana": 200,
+//     "position": [0, 0, 0],
+//     "velocity": [1, 0, 0],
+//     "weapons": [
+//         "fist",
+//         {"damage": 15, "name": "great axe"},
+//         {"damage": 5, "name": "hammer"}]
+// }
+fn main() {
+    // Create a new Flexbuffer builder.
+    let mut builder = Builder::default();
+
+    // The root of the builder can be a singleton, map or vector.
+    // Our monster will be represented with a map.
+    let mut monster = builder.start_map();
+
+    // Use `push` to add elements to a vector or map. Note that it up to the programmer to ensure
+    // duplicate keys are avoided and the key has no null bytes.
+    monster.push("hp", 80);
+    monster.push("mana", 200);
+    monster.push("enraged", true);
+
+    // Let's give our monster some weapons. Use `start_vector` to store a vector.
+    let mut weapons = monster.start_vector("weapons");
+
+    // The first weapon is a fist which has no damage so we'll store it as a string.
+    // Strings in Flexbuffers are utf8 encoded and are distinct from map Keys which are c strings.
+    weapons.push("fist");
+
+    // The monster also has an axe. We'll store it as a map to make it more interesting.
+    let mut axe = weapons.start_map();
+    axe.push("name", "great axe");
+    axe.push("damage", 15);
+    // We're done adding to the axe.
+    axe.end_map();
+
+    // The monster also has a hammer.
+    {
+        let mut hammer = weapons.start_map();
+        hammer.push("name", "hammer");
+        hammer.push("damage", 5);
+        // Instead of calling `hammer.end_map()`, we can just drop the `hammer` for the same effect.
+        // Vectors and maps are completed and serialized when their builders are dropped.
+    }
+
+    // We're done adding weapons.
+    weapons.end_vector();
+
+    // Give the monster some money. Flexbuffers has typed vectors which are smaller than
+    // heterogenous vectors. Elements of typed vectors can be pushed one at a time, as above, or
+    // they can be passed as a slice. This will be stored as a `FlexBufferType::VectorInt`.
+    monster.push("coins", &[5, 10, 25, 25, 25, 100]);
+
+    // Flexbuffer has special types for fixed-length-typed-vectors (if the length is 3 or 4 and the
+    // type is int, uint, or float). They're even more compact than typed vectors.
+    // The monster's position and Velocity will be stored as `FlexbufferType::VectorFloat3`.
+    monster.push("position", &[0.0; 3]);
+    monster.push("velocity", &[1.0, 0.0, 0.0]);
+
+    // Give the monster bright red skin. In rust, numbers are assumed integers until proven
+    // otherwise. We annotate u8 to tell flexbuffers to store it as a FlexbufferType::VectorUInt4.
+    monster.push("color", &[255, 0, 0, 255u8]);
+
+    // End the map at the root of the builder. This finishes the Flexbuffer.
+    monster.end_map();
+
+    // Now the buffer is free to be reused. Let's see the final buffer.
+    let data = builder.view();
+    println!("The monster was serialized in {:?} bytes.", data.len());
+
+    // Let's read and verify the data.
+    let root = Reader::get_root(data).unwrap();
+    println!("The monster: {}", root);
+
+    let read_monster = root.as_map();
+
+    // What attributes does this monster have?
+    let attrs: Vec<_> = read_monster.iter_keys().collect();
+    assert_eq!(
+        attrs,
+        vec!["coins", "color", "enraged", "hp", "mana", "position", "velocity", "weapons"]
+    );
+
+    // index into a vector or map with the `idx` method.
+    let read_hp = read_monster.idx("hp");
+    let read_mana = read_monster.idx("mana");
+    // If `idx` fails it will return a Null flexbuffer Reader
+
+    // Use `as_T` to cast the data to your desired type.
+    assert_eq!(read_hp.as_u8(), 80);
+    assert_eq!(read_hp.as_f32(), 80.0);
+    // If it fails it will return T::default().
+    assert_eq!(read_hp.as_str(), ""); // Its not a string.
+    assert_eq!(read_mana.as_i8(), 0); // 200 is not representable in i8.
+    assert!(read_mana.as_vector().is_empty()); // Its not a vector.
+    assert_eq!(read_monster.idx("foo").as_i32(), 0); // `foo` is not a monster attribute.
+
+    // To examine how your data is stored, check the flexbuffer type and bitwidth.
+    assert!(read_hp.flexbuffer_type().is_int());
+    assert!(read_mana.flexbuffer_type().is_int());
+    // Note that mana=200 is bigger than the maximum i8 so everything in the top layer of the
+    // monster map is stored in 16 bits.
+    assert_eq!(read_hp.bitwidth(), BitWidth::W16);
+    assert_eq!(read_monster.idx("mana").bitwidth(), BitWidth::W16);
+
+    // Use get_T functions if you want to ensure the flexbuffer type matches what you expect.
+    assert_eq!(read_hp.get_i64(), Ok(80));
+    assert!(read_hp.get_u64().is_err());
+    assert!(read_hp.get_vector().is_err());
+
+    // Analogously, the `index` method is the safe version of `idx`.
+    assert!(read_monster.index("hp").is_ok());
+    assert_eq!(
+        read_monster.index("foo").unwrap_err(),
+        ReaderError::KeyNotFound
+    );
+
+    // Maps can also be indexed by usize. They're stored by key so `coins` are the first element.
+    let monster_coins = read_monster.idx(0);
+    // Maps and Vectors can be iterated over.
+    assert!(monster_coins
+        .as_vector()
+        .iter()
+        .map(|r| r.as_u8())
+        .eq(vec![5, 10, 25, 25, 25, 100].into_iter()));
+    // For very speed sensitive applications, you can directly read the slice if all of the
+    // following are true:
+    //
+    // *   The provided data buffer contains a valid flexbuffer.
+    // *   You correctly specify the flexbuffer type and width.
+    // *   The host machine is little endian.
+    // *   The provided data buffer itself is aligned in memory to 8 bytes.
+    //
+    // Vec<u8> has alignment 1 so special care is needed to get your buffer's alignment to 8.
+    #[cfg(target_endian = "little")]
+    {
+        if monster_coins.is_aligned() {
+            assert_eq!(
+                monster_coins.get_slice::<i8>().unwrap(),
+                &[5, 10, 25, 25, 25, 100]
+            );
+        }
+    }
+
+    // Build the answer to life the universe and everything. Reusing a builder resets it. The
+    // reused internals won't need to reallocate leading to a potential 2x speedup.
+    builder.build_singleton(42);
+
+    // The monster is now no more.
+    assert_eq!(builder.view().len(), 3); // Bytes.
+
+    let the_answer = Reader::get_root(builder.view()).unwrap();
+    assert_eq!(the_answer.as_i32(), 42);
+}
+
+#[test]
+fn test_main() {
+    main()
+}
diff --git a/samples/sample_flexbuffers_serde.rs b/samples/sample_flexbuffers_serde.rs
new file mode 100644
index 0000000..359ba45
--- /dev/null
+++ b/samples/sample_flexbuffers_serde.rs
@@ -0,0 +1,81 @@
+// Copyright 2019 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://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.
+
+extern crate flexbuffers;
+extern crate serde;
+#[macro_use]
+extern crate serde_derive;
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+enum Weapon {
+    Fist,
+    Equipment { name: String, damage: i32 },
+}
+
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+struct Color(u8, u8, u8, u8);
+
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+struct Monster {
+    hp: u32,
+    mana: i32,
+    enraged: bool,
+    weapons: Vec<Weapon>,
+    color: Color,
+    position: [f64; 3],
+    velocity: [f64; 3],
+    coins: Vec<u32>,
+}
+
+fn main() {
+    let monster = Monster {
+        hp: 80,
+        mana: 200,
+        enraged: true,
+        color: Color(255, 255, 255, 255),
+        position: [0.0; 3],
+        velocity: [1.0, 0.0, 0.0],
+        weapons: vec![
+            Weapon::Fist,
+            Weapon::Equipment {
+                name: "great axe".to_string(),
+                damage: 15,
+            },
+            Weapon::Equipment {
+                name: "hammer".to_string(),
+                damage: 5,
+            },
+        ],
+        coins: vec![5, 10, 25, 25, 25, 100],
+    };
+    let mut s = flexbuffers::FlexbufferSerializer::new();
+    monster.serialize(&mut s).unwrap();
+
+    let r = flexbuffers::Reader::get_root(s.view()).unwrap();
+
+    // Serialization is similar to JSON. Field names are stored in the buffer but are reused
+    // between all maps and structs.
+    println!("Monster stored in {:?} bytes.", s.view().len());
+    println!("{}", r);
+
+    let monster2 = Monster::deserialize(r).unwrap();
+
+    assert_eq!(monster, monster2);
+}
+
+#[test]
+fn test_main() {
+    main()
+}
diff --git a/samples/sample_text.cpp b/samples/sample_text.cpp
index aca0189..d46185b 100644
--- a/samples/sample_text.cpp
+++ b/samples/sample_text.cpp
@@ -16,14 +16,13 @@
 
 #include "flatbuffers/idl.h"
 #include "flatbuffers/util.h"
-
 #include "monster_generated.h"  // Already includes "flatbuffers/flatbuffers.h".
 
 using namespace MyGame::Sample;
 
 // This is an example of parsing text straight into a buffer and then
 // generating flatbuffer (JSON) text from the buffer.
-int main(int /*argc*/, const char * /*argv*/ []) {
+int main(int /*argc*/, const char * /*argv*/[]) {
   // load FlatBuffer schema (.fbs) and JSON from disk
   std::string schemafile;
   std::string jsonfile;