Enhance auto_encode to take number of struct fields

emit_struct and read_struct takes an additional len:uint parameter which tells
us how many fields the struct we are working on has.

This is required to implement an Encoder for the msgpack [1] serialization
format. To serialize a struct with msgpack you have to use arrays and the size
of the array has to be know before each of the elements are written out. JSON
as an example doesn't have this problem as it uses '[' and ']' delimiters for
arrays.

[1]: www.msgpack.org
Rename memcpy, memmove, memset to prevent any confusion with the C equivalents.

Closes #4203.
doc: Fold information from the memory model interlude in the tutorial elsewhere
Make std::sync::semaphore() public
Factor out base::get_discrim_val from const translation
Allow consts' LLVM types to depend on their initializers.

Loosening the connection between the LLVM type and the Rust type
is necessary to use non-nullary enum constructors as const initializers,
because the const needs to be initialized with data of the actual type of
the variant in question, which is (generally) not the same as the u8
array in the `type_of` type.

Thus, referring to a const now requires casting the LLVM global to the
expected pointer type instead of using it as-is.
Allow consts to be non-nullary enum constructors
Omit needless zeroes for C-like variants of non-C-like enums
Add more tests for enum constants.

The tests have consts defined both before and after their uses in order
to prevent bugs that depend on the order in which they are translated.
Regression tests for passing enum-typed consts by reference.

If the PointerCast in trans_def_lvalue is removed, these cases cause
LLVM assertion failures.
doc: Fix spelling error in macro tutorial
add Option methods for swap_unwrap and map_consume
add Option map_consume_default method
avoid unwrap in Option::map_consume implementation
Fix incorrect error messages in the time library
Fix errors in how parsed time values were used

%u flag takes a value in the range of 1-7. However value needs to be
stored in tm.tm_wday between 0 and 6.
%y takes a two-digit year value. Subtracting 1900_i32 from it is not
needed.
Add range checking in the time library

This was requested in Issue #2350. New function match_digits_in_range
added and used instead of match_digits wherever needed.
Inlining methods/functions in core.

Also inlining some functions which take functions as arguments.
add Option methods for in-place mutation
Merge pull request #4460 from pkgw/pr-tut-typo

doc: Fix spelling error in macro tutorial