Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2018 10:41
Show Gist options
  • Save anonymous/1c5eb389aeacd9c5b894de338f918423 to your computer and use it in GitHub Desktop.
Save anonymous/1c5eb389aeacd9c5b894de338f918423 to your computer and use it in GitHub Desktop.
fn map_type(comptime Type: type) type
{
if (Type == u32) return f32;
return f64;
}
fn compute_result(comptime Type: type) type
{
var computed_value: map_type(Type) = 1.0;
return struct { var data = computed_value; };
}
fn test_return_type_inference(comptime Type: type) @typeOf(compute_result(Type).data)
{
return compute_result(Type).data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment