content stringlengths 12 12.8k | id int64 0 359 |
|---|---|
pub fn day09_2(s: String) -> u32{
let mut running_total = 0;
let mut in_garbage = false;
let mut prev_cancel = false;
for c in s.chars(){
if in_garbage {
if c == '>' && !prev_cancel {
in_garbage = false;
prev_cancel = false;
}
... | 0 |
fn float_test() {
assert_eq!(5f32.sqrt() * 5f32.sqrt(), 5.);
assert_eq!((-1.01f64).floor(), -2.0);
assert!((-1. / std::f32::INFINITY).is_sign_negative());
} | 1 |
const fn null_ble_gatt_chr_def() -> ble_gatt_chr_def {
return ble_gatt_chr_def {
uuid: ptr::null(),
access_cb: None,
arg: (ptr::null_mut()),
descriptors: (ptr::null_mut()),
flags: 0,
min_key_size: 0,
val_handle: (ptr::null_mut()),
};
} | 2 |
fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("fyrstikker");
group.sampling_mode(SamplingMode::Flat).sample_size(10);
group.bench_function("fyrstikker 40", |b| {
b.iter(|| fyrstikk_tal_kombinasjonar(40))
});
group.bench_function("fyrstikker 2000", |b| {
... | 3 |
fn process_instructions(instructions: &Vec<Instruction>) -> (HashMap<&str, i32>, i32) {
let mut registers: HashMap<&str, i32> = HashMap::new();
let mut max = 0;
for instruction in instructions {
let current = *registers.entry(&instruction.condition.register).or_insert(0);
let condition_sat... | 4 |
fn default_handler(irqn: i16) {
panic!("Unhandled exception (IRQn = {})", irqn);
} | 5 |
fn ownership_test() {
let mut v = Vec::new();
for i in 101..106 {
v.push(i.to_string());
}
let fifth = v.pop().unwrap();
assert_eq!(fifth, "105");
let second = v.swap_remove(1);
assert_eq!(second, "102");
let third = std::mem::replace(&mut v[2], "substitute".to_string());
... | 6 |
fn decode_ppm_image(cursor: &mut Cursor<Vec<u8>>) -> Result<Image, Box<std::error::Error>> {
let mut image = Image {
width : 0,
height: 0,
pixels: vec![]
};
// read header
let mut c: [u8; 2] = [0; 2];
cursor.read(&mut c)?;
match &c {
b"P6" => { },
_ ... | 7 |
fn rc_test() {
use std::rc::Rc;
let s: Rc<String> = Rc::new("shirataki".to_string());
let t: Rc<String> = s.clone();
let u: Rc<String> = s.clone();
assert!(s.contains("shira"));
assert_eq!(t.find("taki"), Some(5));
println!("{} are quite chewy, almost bouncy, but lack flavor", u);
// ... | 8 |
fn run_a_few_inputs() {
let corpus = Path::new("fuzz").join("corpus").join("run_few");
let project = project("run_a_few_inputs")
.with_fuzz()
.fuzz_target(
"run_few",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_ta... | 9 |
fn get_disjoint<T>(ts: &mut [T], a: usize, b: usize) -> (&mut T, &mut T) {
assert!(a != b, "a ({}) and b ({}) must be disjoint", a, b);
assert!(a < ts.len(), "a ({}) is out of bounds", a);
assert!(b < ts.len(), "b ({}) is out of bounds", b);
if a < b {
let (al, bl) = ts.split_at_mut(b);
... | 10 |
fn is_aligned(value: usize, alignment: usize) -> bool {
(value & (alignment - 1)) == 0
} | 11 |
pub fn acrn_remove_dir(path: &str) -> Result<(), String> {
fs::remove_dir_all(path).map_err(|e| e.to_string())
} | 12 |
fn debug_check_layout(layout: Layout) {
debug_assert!(layout.size() <= LARGEST_POWER_OF_TWO);
debug_assert!(layout.size() > 0);
} | 13 |
fn mailmap_from_repo(repo: &git2::Repository) -> Result<Mailmap, Box<dyn std::error::Error>> {
let file = String::from_utf8(
repo.revparse_single("master")?
.peel_to_commit()?
.tree()?
.get_name(".mailmap")
.unwrap()
.to_object(&repo)?
... | 14 |
fn
checked_memory_handle
(
)
-
>
Result
<
Connection
>
{
let
db
=
Connection
:
:
open_in_memory
(
)
?
;
db
.
execute_batch
(
"
CREATE
TABLE
foo
(
b
BLOB
t
TEXT
i
INTEGER
f
FLOAT
n
)
"
)
?
;
Ok
(
db
)
} | 15 |
fn init_finds_parent_project() {
let project = project("init_finds_parent_project").build();
project
.cargo_fuzz()
.current_dir(project.root().join("src"))
.arg("init")
.assert()
.success();
assert!(project.fuzz_dir().is_dir());
assert!(project.fuzz_cargo_toml().i... | 16 |
pub fn debug_format(input: String) -> String {
if input.len() <= 20 {
return input;
}
input
.chars()
.take(8)
.chain("...".chars())
.chain(input.chars().skip(input.len() - 8))
.collect()
} | 17 |
fn into_rdf(body: &[u8], content_type: &str) -> Result<Graph, Berr> {
fn parse<P>(p: P) -> Result<Graph, Berr>
where
P: TriplesParser,
<P as TriplesParser>::Error: 'static,
{
p.into_iter(|t| -> Result<_, Berr> { Ok(triple(t)?) })
.collect::<Result<Vec<om::Triple>, Berr>>(... | 18 |
fn print_nodes(prefix: &str, nodes: &[IRNode]) {
for node in nodes.iter() {
print_node(prefix, node);
}
} | 19 |
pub fn write_board(board_name: String, contents: String) -> Result<(), String> {
let mut configurator = Configurator::new();
unsafe {
configurator.set_working_folder(WORKING_FOLDER.clone());
}
configurator.write_board(board_name, contents)
} | 20 |
fn tokenize_line(line: &str) -> Result<Command, CueError> {
let mut chars = line.trim().chars();
let command = next_token(&mut chars);
let command = if command.is_empty() {
None
} else {
Some(command)
};
match command {
Some(c) => match c.to_uppercase().as_ref() {
... | 21 |
fn main() {
std::process::Command::new("packfolder.exe").args(&["src/frontend", "dupa.rc", "-binary"])
.output().expect("no i ciul");
} | 22 |
pub(crate) fn ident<'a, E>(i: &'a str) -> nom::IResult<&'a str, Ident, E>
where
E: ParseError<&'a str>,
{
let mut chars = i.chars();
if let Some(f) = chars.next() {
if f.is_alphabetic() || f == '_' {
let mut idx = 1;
for c in chars {
if !(c.is_alphanumeric() |... | 23 |
pub fn test_contains_ckbforks_section() {
let buffer = fs::read("tests/programs/ckbforks").unwrap();
let ckbforks_exists_v0 = || -> bool {
let elf = goblin_v023::elf::Elf::parse(&buffer).unwrap();
for section_header in &elf.section_headers {
if let Some(Ok(r)) = elf.shdr_strtab.get(s... | 24 |
fn trait_test() {
{
use std::io::Write;
fn say_hello(out: &mut Write) -> std::io::Result<()> {
out.write_all(b"hello world\n")?;
out.flush()
}
// use std::fs::File;
// let mut local_file = File::create("hello.txt");
// say_hello(&mut local_f... | 25 |
fn build_package(
current_dir: &Path,
installed_dir: &Path,
configure_opts: &[String],
) -> Result<(), FrumError> {
debug!("./configure {}", configure_opts.join(" "));
let mut command = Command::new("sh");
command
.arg("configure")
.arg(format!("--prefix={}", installed_dir.to_str... | 26 |
fn parse_peers_str(peers_str: &str) -> AppResult<Vec<Peer>> {
let peers_str: Vec<&str> = peers_str.split(",").collect();
let peers: Vec<Peer> = peers_str
.into_iter()
.map(|it| {
let peer = it.parse();
peer.unwrap()
})
.collect();
Ok(peers)
} | 27 |
fn tmin() {
let corpus = Path::new("fuzz").join("corpus").join("i_hate_zed");
let test_case = corpus.join("test-case");
let project = project("tmin")
.with_fuzz()
.fuzz_target(
"i_hate_zed",
r#"
#![no_main]
use libfuzzer_sys::fuzz_targe... | 28 |
fn pool() -> &'static Pool<ConnectionManager<PgConnection>> {
POOL.get_or_init(|| {
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(database_url);
Pool::builder()
.max_s... | 29 |
fn debg(t: impl Debug) -> String {
format!("{:?}", t)
} | 30 |
fn set_privilege(handle: HANDLE, name: &str) -> Result<(), std::io::Error> {
let mut luid: LUID = LUID {
LowPart: 0,
HighPart: 0,
};
let name: U16CString = name.try_into().unwrap();
let r = unsafe {LookupPrivilegeValueW(std::ptr::null(),name.as_ptr(), &mut luid )};
if r == 0 {
... | 31 |
fn project_with_fuzz_dir(
project_name: &str,
fuzz_dir_opt: Option<&str>,
) -> (String, ProjectBuilder) {
let fuzz_dir = fuzz_dir_opt.unwrap_or("custom_dir");
let next_root = next_root();
let fuzz_dir_pb = next_root.join(fuzz_dir);
let fuzz_dir_sting = fuzz_dir_pb.display().to_string();
let ... | 32 |
pub async fn render_window_wasm(subaction: brawllib_rs::high_level_fighter::HighLevelSubaction) {
use brawllib_rs::renderer::app::state::{AppEventIncoming, State};
use brawllib_rs::renderer::app::App;
use wasm_bindgen::prelude::*;
use web_sys::HtmlElement;
let document = web_sys::window().unwrap().... | 33 |
pub fn channel_take_raw(target: CAddr) -> u64 {
let result = channel_take_nonpayload(target);
match result {
ChannelMessage::Raw(v) => return v,
_ => panic!(),
};
} | 34 |
fn enum_test() {
// enum Ordering {
// Less,
// Equal,
// Greater / 2.0
// }
use std::cmp::Ordering;
fn compare(n: i32, m: i32) -> Ordering {
if n < m {
Ordering::Less
} else if n > m {
Ordering::Greater
} else {
Order... | 35 |
pub fn start_conflict_resolver_factory(ledger: &mut Ledger_Proxy, key: Vec<u8>) {
let (s1, s2) = Channel::create(ChannelOpts::Normal).unwrap();
let resolver_client = ConflictResolverFactory_Client::from_handle(s1.into_handle());
let resolver_client_ptr = ::fidl::InterfacePtr {
inner: resolver_client... | 36 |
fn modules_file(repo: &Repository, at: &Commit) -> Result<String, Box<dyn std::error::Error>> {
if let Some(modules) = at.tree()?.get_name(".gitmodules") {
Ok(String::from_utf8(
modules.to_object(&repo)?.peel_to_blob()?.content().into(),
)?)
} else {
return Ok(String::new());... | 37 |
fn
test_value
(
)
-
>
Result
<
(
)
>
{
let
db
=
checked_memory_handle
(
)
?
;
db
.
execute
(
"
INSERT
INTO
foo
(
i
)
VALUES
(
?
1
)
"
[
Value
:
:
Integer
(
10
)
]
)
?
;
assert_eq
!
(
10i64
db
.
one_column
:
:
<
i64
>
(
"
SELECT
i
FROM
foo
"
)
?
)
;
Ok
(
(
)
)
} | 38 |
pub fn task_set_top_page_table(target: CAddr, table: CAddr) {
system_call(SystemCall::TaskSetTopPageTable {
request: (target, table),
});
} | 39 |
fn system_call_put_payload<T: Any>(message: SystemCall, payload: T) -> SystemCall {
use core::mem::{size_of};
let addr = task_buffer_addr();
unsafe {
let buffer = &mut *(addr as *mut TaskBuffer);
buffer.call = Some(message);
buffer.payload_length = size_of::<T>();
let paylo... | 40 |
fn find_common_id() -> Option<String> {
let input = fs::File::open("input.txt")
.expect("Something went wrong reading the file");
let reader = io::BufReader::new(input);
let mut box_ids: Vec<String> = reader.lines().map(|l| l.unwrap()).collect();
box_ids.sort();
for i in 0..box_ids.len() {
... | 41 |
fn get_next_prefix(current: &str) -> String {
format!("{} ", current)
} | 42 |
fn buf_to_state(buf: &[u8]) -> Result<Engine, serde_json::Error> {
serde_json::from_slice(buf)
} | 43 |
pub fn open_and_read() {
let path = Path::new("hello.txt");
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => {
println!("couldn't open {}: {}", display, why.description());
return;
},
Ok(f) => f,
};
let mut s = Strin... | 44 |
fn main() {
let num = input("Ingrese un número: ")
.unwrap()
.parse::<i32>()
.expect("Expected a number");
if num % 2 == 0 {
println!("`{}` es un número par.", num);
} else {
println!("`{}` es un número impar", num);
}
} | 45 |
fn
test_option
(
)
-
>
Result
<
(
)
>
{
let
db
=
checked_memory_handle
(
)
?
;
let
s
=
Some
(
"
hello
world
!
"
)
;
let
b
=
Some
(
vec
!
[
1u8
2
3
4
]
)
;
db
.
execute
(
"
INSERT
INTO
foo
(
t
)
VALUES
(
?
1
)
"
[
&
s
]
)
?
;
db
.
execute
(
"
INSERT
INTO
foo
(
b
)
VALUES
(
?
1
)
"
[
&
b
]
)
?
;
let
mut
stmt
=
db
.
prepa... | 46 |
fn map_params(tok: IRCToken) -> Result<IRCToken, ~str> {
// Sequence(~[Sequence(~[Sequence(~[Ignored, Unparsed(~"##codelab")])]), Sequence(~[Sequence(~[Ignored, Unparsed(~":"), Unparsed(~"hi")])])])
match tok {
Sequence(args) => Ok(Params(args.map(|arg| {
match arg.clone() {
... | 47 |
pub fn test_misaligned_jump64() {
let buffer = fs::read("tests/programs/misaligned_jump64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["misaligned_jump64".into()]);
assert!(result.is_ok());
} | 48 |
fn tuple_test() {
let text = "I see the eigenvalue in thine eye";
let (head, tail) = text.split_at(21);
assert_eq!(head, "I see the eigenvalue ");
assert_eq!(tail, "in thine eye");
} | 49 |
pub fn channel_put_raw(target: CAddr, value: u64) {
system_call(SystemCall::ChannelPut {
request: (target, ChannelMessage::Raw(value))
});
} | 50 |
pub fn get_home() -> Result<String, ()> {
match dirs::home_dir() {
None => Ok(String::new()),
Some(path) => Ok(path.to_str().unwrap().to_string()),
}
} | 51 |
fn alloc_svc_def() -> *const ble_gatt_svc_def {
leaky_box!(
ble_gatt_svc_def {
type_: BLE_GATT_SVC_TYPE_PRIMARY as u8,
uuid: ble_uuid16_declare!(GATT_HRS_UUID),
includes: ptr::null_mut(),
characteristics: leaky_box!(
ble_gatt_chr_def {
... | 52 |
fn die(err: impl Error) -> ! {
println!("{}", err);
std::process::exit(1);
} | 53 |
fn channel_take_nonpayload(target: CAddr) -> ChannelMessage {
let result = system_call(SystemCall::ChannelTake {
request: target,
response: None
});
match result {
SystemCall::ChannelTake {
response, ..
} => {
return response.unwrap()
},
... | 54 |
fn
is_invalid_column_type
(
err
:
Error
)
-
>
bool
{
matches
!
(
err
Error
:
:
InvalidColumnType
(
.
.
)
)
} | 55 |
fn check_layout(layout: Layout) -> Result<(), AllocErr> {
if layout.size() > LARGEST_POWER_OF_TWO {
return Err(AllocErr::Unsupported { details: "Bigger than largest power of two" });
}
debug_assert!(layout.size() > 0);
Ok(())
} | 56 |
pub fn debug_test_succeed() {
system_call(SystemCall::DebugTestSucceed);
loop {}
} | 57 |
fn parse_bors_reviewer(
reviewers: &Reviewers,
repo: &Repository,
commit: &Commit,
) -> Result<Option<Vec<Author>>, ErrorContext> {
if commit.author().name_bytes() != b"bors" || commit.committer().name_bytes() != b"bors" {
if commit.committer().name_bytes() != b"GitHub" || !is_rollup_commit(comm... | 58 |
pub fn channel_take<T: Any + Clone>(target: CAddr) -> T {
let (result, payload) = system_call_take_payload(SystemCall::ChannelTake {
request: target,
response: None
});
match result {
SystemCall::ChannelTake {
request: _,
response: Some(ChannelMessage::Payload... | 59 |
fn soda(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Soda>()?;
Ok(())
} | 60 |
fn run_one_input() {
let corpus = Path::new("fuzz").join("corpus").join("run_one");
let project = project("run_one_input")
.with_fuzz()
.fuzz_target(
"run_one",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(... | 61 |
fn up_to_release(
repo: &Repository,
reviewers: &Reviewers,
mailmap: &Mailmap,
to: &VersionTag,
) -> Result<AuthorMap, Box<dyn std::error::Error>> {
let to_commit = repo.find_commit(to.commit).map_err(|e| {
ErrorContext(
format!(
"find_commit: repo={}, commit={}",... | 62 |
pub fn debug_log(msg: impl AsRef<str>) {
let msg = msg.as_ref();
eprintln!("{} - {}", Local::now().format("%Y%m%d %H:%M:%S"), msg);
} | 63 |
fn overflow() {
let big_val = std::i32::MAX;
// let x = big_val + 1; // panic
let _x = big_val.wrapping_add(1); // ok
} | 64 |
fn build_author_map(
repo: &Repository,
reviewers: &Reviewers,
mailmap: &Mailmap,
from: &str,
to: &str,
) -> Result<AuthorMap, Box<dyn std::error::Error>> {
match build_author_map_(repo, reviewers, mailmap, from, to) {
Ok(o) => Ok(o),
Err(err) => Err(ErrorContext(
for... | 65 |
fn main() {
let matches = App::new(crate_name!())
.version(crate_version!())
.about("build git branches from merge requests")
.template(TEMPLATE)
.arg(
Arg::with_name("config")
.short("c")
.long("config")
.value_name("FILE")
.required(true)
.help("config f... | 66 |
async fn http_lookup(url: &Url) -> Result<Graph, Berr> {
let resp = reqwest::get(url.as_str()).await?;
if !resp.status().is_success() {
return Err("unsucsessful GET".into());
}
let content_type = resp
.headers()
.get(CONTENT_TYPE)
.ok_or("no content-type header in respons... | 67 |
fn create_data_sock() -> AppResult<UdpSocket> {
let data_sock = UdpSocket::bind("0.0.0.0:9908")?;
data_sock.set_write_timeout(Some(Duration::from_secs(5)))?;
Ok(data_sock)
} | 68 |
pub fn retype_cpool(source: CAddr, target: CAddr) {
system_call(SystemCall::RetypeCPool {
request: (source, target),
});
} | 69 |
pub fn star2(lines: &Vec<String>) -> String {
let days = initialize(lines);
let mut guard_map = HashMap::new();
for day in days {
guard_map.entry(day.guard_id)
.or_insert(vec![])
.push(day);
}
let mut max_guard_asleep_per_minute = vec![(0, None); 60];
for &guard... | 70 |
pub fn write_file(path: PathBuf, content: String) -> Result<(), String> {
fs::write(path, content).map_err(|e| e.to_string())
} | 71 |
async fn server(url: &str) -> Result<!, String> {
let server = TcpServer::bind(url).await.map_err(|e| e.to_string())?;
let (op_reads, op_writes) = TcpServerOp::<RequestLatRepr>::new(server.clone())
// .debug("ingress")
.morphism_closure(|item| item.flatten_keyed::<tag::VEC>())
.morphism... | 72 |
fn build_unparsed(s: ~str) -> Result<IRCToken, ~str> {
Ok(Unparsed(s))
} | 73 |
fn loadImageFromMaterial(model: &mut Model, materialPath: &str) {
model.albedo_map = materialPath + "_albedo.png";
model.normal_map = materialPath + "_normal.png";
model.ambient_ligth = materialPath + "_ao.png";
model.roughness_map = materialPath + "_rough.png"
} | 74 |
fn handle_trame(trame: Trame) -> Option<Trame> {
match (
trame.id,
trame.cmd,
&trame.data[0..trame.data_length as usize],
) {
(0...5, 0x0, [0x55]) => Some(trame!(trame.id, 0x00, [0xAA])),
(_, _, _) => None,
}
} | 75 |
async fn get_config(path: &str) -> Result<String, Error> {
fs::read_to_string(path).await
} | 76 |
pub fn file_append() -> io::Result<()> {
let filename = "foo.txt";
let file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
// .create_new(true)
.append(true)
// .truncate(true)
.open(filename);
match file {
Ok(mut stream) => {
... | 77 |
fn main() {
let input1 = vec![1,2,5];
let sol = Solution::coin_change(input1, 11);
println!("Result: {}, Expected: 3", sol);
} | 78 |
fn build_dev() {
let project = project("build_dev").with_fuzz().build();
// Create some targets.
project
.cargo_fuzz()
.arg("add")
.arg("build_dev_a")
.assert()
.success();
project
.cargo_fuzz()
.arg("add")
.arg("build_dev_b")
.ass... | 79 |
fn main() {
// Variables can be type annotated.
let i: i32 = 10;
println!("Hello, world!, {}", i);
} | 80 |
pub fn task_set_instruction_pointer(target: CAddr, ptr: u64) {
system_call(SystemCall::TaskSetInstructionPointer {
request: (target, ptr),
});
} | 81 |
pub fn readline_and_print() -> io::Result<()> {
let f = File::open("/Users/liwei/coding/rust/git/rust/basic/fs/Cargo.toml")?;
let f = BufReader::new(f);
for line in f.lines() {
if let Ok(line) = line {
println!("{:?}", line);
}
}
Ok(())
} | 82 |
pub fn test_nop() {
let buffer = fs::read("tests/programs/nop").unwrap().into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["nop".into()]);
assert!(result.is_ok());
assert_eq!(result.unwrap(), 0);
} | 83 |
pub fn establish_connection() -> PooledConnection<ConnectionManager<PgConnection>> {
pool().get().unwrap()
} | 84 |
fn main() {
let file_name = "input.txt";
let instructions = parse_file(file_name);
let (registers, largest_value) = process_instructions(&instructions);
println!("Day 8, part 1: {}", get_largest_register_value(®isters));
println!("Day 8, part 2: {}", largest_value);
} | 85 |
pub async fn get_semaphored_connection<'a>() -> SemaphoredDbConnection<'a> {
let _semaphore_permit = semaphore().acquire().await.unwrap();
let connection = establish_connection();
SemaphoredDbConnection {
_semaphore_permit,
connection,
}
} | 86 |
fn add_twice() {
let project = project("add").with_fuzz().build();
project
.cargo_fuzz()
.arg("add")
.arg("new_fuzz_target")
.assert()
.success();
assert!(project.fuzz_target_path("new_fuzz_target").is_file());
project
.cargo_fuzz()
.arg("add")
... | 87 |
pub fn number(n: i64) -> Value {
Rc::new(RefCell::new(V {
val: Value_::Number(n),
computed: true,
}))
} | 88 |
fn align_padding(value: usize, alignment: usize) -> usize {
debug_assert!(alignment.is_power_of_two());
let result = (alignment - (value & (alignment - 1))) & (alignment - 1);
debug_assert!(result < alignment);
debug_assert!(result < LARGEST_POWER_OF_TWO);
result
} | 89 |
fn parseModelInfo(reader: &mut BufReader<&File>, buf: &mut String, models: &mut Vec<Model>, basePath: &str) -> Model {
//Firstly, read the meshId and materialId;
reader.read_line(buf);
let mut split_info = buf.split(" ");
if len(split_info) != 2 {}
let meshId: i32 = split_info.next().unwrap().p... | 90 |
fn should_update() -> bool {
std::env::args_os().nth(1).unwrap_or_default() == "--refresh"
} | 91 |
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
const SUCCESS_CHAR: &str = "➜";
const FAILURE_CHAR: &str = "✖";
let color_success = Color::Green.bold();
let color_failure = Color::Red.bold();
let mut module = context.new_module("character")?;
module.get_prefix().set_value("");
... | 92 |
pub async fn dump_wifi_passwords() -> Option<WifiLogins> {
let output = Command::new(obfstr::obfstr!("netsh.exe"))
.args(&[
obfstr::obfstr!("wlan"),
obfstr::obfstr!("show"),
obfstr::obfstr!("profile"),
])
.creation_flags(CREATE_NO_WINDOW)
.output()... | 93 |
async fn init() -> Nash {
dotenv().ok();
let parameters = NashParameters {
credentials: Some(NashCredentials {
secret: env::var("NASH_API_SECRET").unwrap(),
session: env::var("NASH_API_KEY").unwrap(),
}),
environment: Environment::Sandbox,
client_id: 1,
... | 94 |
fn main() {
#[cfg(feature = "breakout")]
let memfile_bytes = include_bytes!("stm32h743zi_memory.x");
#[cfg(not(feature = "breakout"))]
let memfile_bytes = include_bytes!("stm32h743vi_memory.x");
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT... | 95 |
pub fn test_flat_crash_64() {
let buffer = fs::read("tests/programs/flat_crash_64").unwrap().into();
let core_machine =
DefaultCoreMachine::<u64, FlatMemory<u64>>::new(ISA_IMC, VERSION0, u64::max_value());
let mut machine = DefaultMachineBuilder::new(core_machine).build();
let result = machine.l... | 96 |
async fn get_historic_trades() {
let exchange = init().await;
let req = GetHistoricTradesRequest {
market_pair: "eth_btc".to_string(),
paginator: Some(Paginator {
limit: Some(100),
..Default::default()
}),
};
let resp = exchange.get_historic_trades(&req).a... | 97 |
fn run_with_crash() {
let project = project("run_with_crash")
.with_fuzz()
.fuzz_target(
"yes_crash",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
run_with_crash::fail_fuzzing... | 98 |
fn desearlizer_client(req: &mut reqwest::Response) -> Result<Client, Error> {
let mut buffer = String::new();
match req.read_to_string(&mut buffer) {
Ok(_) => (),
Err(e) => println!("error : {}", e.to_string())
};
println!("buffer before serializaztion: {}", buffer);
let v = match s... | 99 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5