This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
use std::net::{TcpStream, SocketAddr, ToSocketAddrs}; | |
use std::io::prelude::*; | |
use std::collections::*; | |
#[derive(Debug)] | |
pub enum Method { | |
GET, | |
POST, | |
PUT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let num1 = vec![2, 3]; | |
let num2 = vec![2, 3]; | |
let address1 = &num1 as *const Vec<i32>; | |
let address2 = &num2 as *const Vec<i32>; | |
let number1 = address1 as i32; | |
let number2 = address2 as i32; | |
println!("{}", number1 % 13); | |
println!("{}", number2 % 13); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::alloc::{alloc, dealloc, Layout}; | |
//use std::fmt::Pointer; | |
fn main() -> () { | |
// Number of elements to allocate | |
const NUM_ELEMENTS: usize = 1024; | |
// Size of each element in bytes | |
const ELEMENT_SIZE: usize = 64; // Assuming 4 bytes per element (e.g., 32-bit integer) | |
// Calculate total size in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::alloc::{alloc, dealloc, Layout}; | |
//use std::fmt::Pointer; | |
fn main() -> () { | |
// Number of elements to allocate | |
const NUM_ELEMENTS: usize = 100; | |
// Size of each element in bytes | |
const ELEMENT_SIZE: usize = 1024; // Assuming 4 bytes per element (e.g., 32-bit integer) | |
// Calculate total size in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::alloc::{alloc, dealloc, Layout}; | |
//use std::fmt::Pointer; | |
fn main() -> () { | |
// Number of elements to allocate | |
const NUM_ELEMENTS: usize = 100; | |
// Size of each element in bytes | |
const ELEMENT_SIZE: usize = 64; // Assuming 4 bytes per element (e.g., 32-bit integer) | |
// Calculate total size in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::alloc::{alloc, dealloc, Layout}; | |
//use std::fmt::Pointer; | |
fn main() -> () { | |
// Number of elements to allocate | |
const NUM_ELEMENTS: usize = 100; | |
// Size of each element in bytes | |
const ELEMENT_SIZE: usize = 8; // Assuming 4 bytes per element (e.g., 32-bit integer) | |
// Calculate total size in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::alloc::{alloc, dealloc, Layout}; | |
//use std::fmt::Pointer; | |
fn main() { | |
// Number of elements to allocate | |
const NUM_ELEMENTS: usize = 100; | |
// Size of each element in bytes | |
const ELEMENT_SIZE: usize = 4; // Assuming 4 bytes per element (e.g., 32-bit integer) | |
// Calculate total size in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#[allow(dead_code)] | |
enum Point { | |
Nothing, | |
TuplePoint(i32, i32), | |
StructPoint { | |
x: i32, | |
y: i32 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut sum: u64 = 0; | |
for x in 0..=32 { | |
// Calculate the term inside the summation | |
let term: f64 = (50.0 * 1e8) / (2.0_f64.powi(x as i32)); | |
println!("{} {}", x, term.to_string()); | |
// Take the floor of the result | |
let floor_term: u64 = term.floor() as u64; | |
// Add it to the sum | |
sum += floor_term; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::path::PathBuf; | |
use clap::{arg, command, value_parser, ArgAction, Command}; | |
fn main() { | |
let matches = command!() // requires `cargo` feature | |
.arg(arg!([name] "Optional name to operate on")) | |
.arg( | |
arg!( | |
-c --config <FILE> "Sets a custom config file" |