I am learning Rust, and created a simple binary search bot for the guessing game the book walks you through. I currently create the number the bot should guess into the function, but technically the bot function shouldn't have access to the secret number variable. I want to initialize it somewhere else, but not have full access to it. In C# I'd normally create my variable at a class level scope. What is the equivalent in Rust? NB: The closest language I've ever used to Rust is Golang for work. I have an OOP background. I was Googling around and it looks like what I want in Rust would be like making a bot manager which calls a function that has a callback to the manager of when it guesses which checks it against the secret number there?
A tool for sharing your source code with the world!