Код: Выделить всё
State MoveForward(in Path path);
< /code>
Path< /code> - ref struct < /code>
State
Теперь у меня есть еще одна вспомогательная функция
Код: Выделить всё
bool TryMoveForward(in Path path, ref State state)
{
// which does something like:
state = MoveForward(path); // "line A"
return !state.IsEnd(); // IsEnd determined by integer != -1
}
< /code>
At the "line A" I am getting the error CS8347: Cannot use a result of 'MoveForward' in this context because it may expose variables referenced by parameter 'path' outside of their declaration scope.
But I think this shouldn't be the case or atleast compiler can be smart enough to avoid throwing this error for few reasons:
[*]State is created just with integers (Compiler can look into the usage of path
«Состояние», является структурой рефлексии, которая не несет никакой «ref», чтобы сбежать. Параметр.
Если я удалю в в перемещении Ошибка исчезает. Я хочу сохранить «in» < /p>
Если я разделяю линию, у меня нет никакого способа избежать ошибки. Например: < /p>
Код: Выделить всё
var result = MoveForward(path); // "line A"
state = result;
return !state.IsEnd(); // IsEnd determined by integer != -1
< /code>
Getting CS8352: Cannot use variable 'result' in this context because it may expose referenced variables outside of their declaration scope.
Код: Выделить всё
state
Подробнее здесь: https://stackoverflow.com/questions/791 ... -parameter