content stringlengths 12 392k | id int64 0 1.08k |
|---|---|
fn largest(list: &[i32]) -> i32 {
let mut largest = list[0];
for &number in list {
if number > largest {
largest = number;
}
}
return largest;
} | 300 |
pub fn create_puzzle(level: usize) -> String {
let board = binoxxo::bruteforce::create_puzzle_board(BOARD_SIZE, level);
board.to_string()
} | 301 |
fn main() {
create_wrapper_file();
generate_bindings();
config_linker();
} | 302 |
fn atoi(s: &str) -> i64 {
i64::from_str_radix(s, 10).unwrap()
} | 303 |
pub fn write_i16<W>(wr: &mut W, val: i16) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::I16));
write_data_i16(wr, val)
} | 304 |
pub fn solve(input: &str) -> Option<Box<usize>> {
let sum_of_counts = input
.trim_end()
.split("\n\n")
.map(|group| group.chars().filter(|ch| *ch != '\n').collect::<HashSet<_>>().len())
.sum();
Some(Box::new(sum_of_counts))
} | 305 |
fn test_let() {
let module = make_module(
indoc! {r#"
-- taken from http://learnyouahaskell.com/syntax-in-functions#pattern-matching
str_imc w h =
let bmi = w / h ^ 2
in if bmi <= 18.5 then "You're underweight, you emo, you!"
elif bm... | 306 |
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);
} | 307 |
pub fn main() {
let game = Game::new();
game_loop(game, 240, 0.1, |g| {
g.game.your_update_function();
}, |g| {
g.game.your_render_function();
});
} | 308 |
fn get_platform_dependent_data_dirs() -> Vec<PathBuf> {
let xdg_data_dirs_variable = var("XDG_DATA_DIRS")
.unwrap_or(String::from("/usr/local/share:/usr/local"));
let xdg_dirs_iter = xdg_data_dirs_variable.split(':').map(|s| Some(PathBuf::from(s)));
let dirs = if cfg!(target_os = "macos") {
... | 309 |
fn main() {
let n = read::<u64>();
let mut coefs = vec![(3_i64, 1_i64); 64];
for i in 1..64 {
let new_a = ((coefs[i - 1].0).pow(2) + (coefs[i - 1].1).pow(2) * 5) % 1000;
let new_b = (2 * coefs[i - 1].0 * coefs[i - 1].1) % 1000;
coefs[i] = (new_a, new_b);
}
let mut ans = (1,... | 310 |
pub fn unary_num(t_unary: Token, n_simple_numeric: Node) -> Node {
let mut numeric_value = if let Node::Int(int_value) = n_simple_numeric { int_value } else { panic!(); };
if let Token::T_UNARY_NUM(polarty) = t_unary {
match polarty.as_ref() {
"+" => (),
"-" => { numeric_value =... | 311 |
pub fn b(b: BuiltIn) -> Value {
Rc::new(RefCell::new(V {
val: Value_::BuiltIn(b),
computed: true,
}))
} | 312 |
pub(crate) fn create_array_iterator_prototype(agent: &Agent) -> Value {
let proto = Value::new_object(agent.intrinsics.iterator_prototype.clone());
proto
.set(
agent,
ObjectKey::from("next"),
Value::new_builtin_function(agent, next, false),
)
.unwrap(... | 313 |
pub unsafe fn set_tid_address(data: *mut c_void) -> Pid {
imp::syscalls::tls::set_tid_address(data)
} | 314 |
pub extern "x86-interrupt" fn serial_1() { CommonInterruptHandler(36); } | 315 |
pub extern "x86-interrupt" fn parallel_2() { CommonInterruptHandler(37); } | 316 |
pub fn add_history(history_type: HistoryType, history_path: String) -> Result<(), &'static str> {
let path_buf = Path::new(&history_path);
if !(path_buf.is_dir() || path_buf.is_file()) {
return Err("Not a validate dir or file path.");
}
let mut configurator = Configurator::new();
configurato... | 317 |
fn extract_zip(data: &Vec<u8>, path: &Path) -> crate::Result<()> {
let cursor = Cursor::new(data);
let mut zipa = ZipArchive::new(cursor)?;
for i in 0..zipa.len() {
let mut file = zipa.by_index(i)?;
let dest_path = path.join(file.name());
let parent = dest_path.parent().expect("Failed to get parent"... | 318 |
pub async fn client_async_tls_with_connector<R, S>(
request: R,
stream: S,
connector: Option<Connector>,
) -> Result<(WebSocketStream<ClientStream<S>>, Response), Error>
where
R: IntoClientRequest + Unpin,
S: 'static + tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin,
AutoStream<S>: Unpin,
{... | 319 |
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... | 320 |
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()
},
... | 321 |
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 => {
... | 322 |
pub fn assert<E> (cond: bool, err: E) -> Result<(), E> {
if cond {
Ok(())
} else {
Err(err)
}
} | 323 |
fn read_num(cursor: &mut Cursor<Vec<u8>>) -> Result<u32, Box<std::error::Error>> {
let mut v: Vec<u8> = vec![];
let mut c: [u8; 1] = [0];
// consume whitespace
loop {
cursor.read(&mut c)?;
match &c {
b" " | b"\t" | b"\n" => { },
_ => { cursor.s... | 324 |
pub(crate) fn assignment_statement(i: Input) -> NodeResult {
alt((
single::single_assignment_statement,
abbreviated::abbreviated_assignment_statement,
multiple_assignment_statement,
))(i)
} | 325 |
fn a_data_model_can_be_generated_from_a_schema() {
let col_types = &[
ColumnTypeFamily::Int,
ColumnTypeFamily::Float,
ColumnTypeFamily::Boolean,
ColumnTypeFamily::String,
ColumnTypeFamily::DateTime,
ColumnTypeFamily::Binary,
ColumnTypeFamily::Json,
Col... | 326 |
pub fn write_pfix<W>(wr: &mut W, val: u8) -> Result<(), FixedValueWriteError>
where W: Write
{
assert!(val < 128);
write_fixval(wr, Marker::FixPos(val))
} | 327 |
pub fn pretty_print(ir: &std::collections::HashMap<String, IRFunction>) {
for (_, func) in ir {
println!("Function-'{}':", func.name);
println!(" Arguments:");
for param in func.parameters.iter() {
println!(" {}: {:?}", param.name, param.param_type);
}
for sta... | 328 |
fn compound_foreign_keys_are_preserved_when_generating_data_model_from_a_schema() {
let expected_data_model = Datamodel {
models: vec![
Model {
database_name: None,
name: "City".to_string(),
documentation: None,
is_embedded: false,
... | 329 |
pub fn main(args: Vec<String>) -> io::Result<()> {
// if no arguments are passed, use current working dir
let cwd = vec![".".to_string()];
let mut files: &Vec<String> = &args;
if files.len() == 0 {
files = &cwd;
}
_ls(files, &mut io::stdout())
} | 330 |
fn soda(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Soda>()?;
Ok(())
} | 331 |
fn generate_thanks() -> Result<BTreeMap<VersionTag, AuthorMap>, Box<dyn std::error::Error>> {
let path = update_repo("https://github.com/rust-lang/rust.git")?;
let repo = git2::Repository::open(&path)?;
let mailmap = mailmap_from_repo(&repo)?;
let reviewers = Reviewers::new()?;
let mut versions = g... | 332 |
pub async fn connect_async_with_config<R>(
request: R,
config: Option<WebSocketConfig>,
) -> Result<(WebSocketStream<ConnectStream>, Response), Error>
where
R: IntoClientRequest + Unpin,
{
let request: Request = request.into_client_request()?;
let domain = domain(&request)?;
let port = port(&re... | 333 |
fn send_err(stream: &mut TcpStream, err: Error) {
let _ = stream.write(err.to_string().as_bytes()).expect("failed a write");
} | 334 |
unsafe fn sift<T, F: Fn(&T, &T) -> bool>(mut root: *mut T, mut order: usize, f: F) {
while order > 1 {
let new_root = near_heap_ultimate_root_ptr(root, order, &f);
order = match ((root as usize) - (new_root as usize))/mem::size_of::<T>() {
0 => return,
1 => order - 2,
... | 335 |
pub fn challenge_7() {
let mut file = File::open("data/7good.txt").unwrap();
let mut all_file = String::new();
file.read_to_string(&mut all_file).unwrap();
let data = base64::decode(&all_file).unwrap();
let key = "YELLOW SUBMARINE".as_bytes().to_vec();
let out = crypto::aes_decrypt_ecb(&data, ... | 336 |
fn test_encode_decode(enc: Intermediate) {
use wormcode_bits::{Decode, Encode};
let b: B<28> = enc.encode();
let dec = Intermediate::decode_option(b);
assert_eq!(Some(enc), dec);
} | 337 |
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]| {
... | 338 |
fn system_call(message: SystemCall) -> SystemCall {
let addr = task_buffer_addr();
unsafe {
let buffer = &mut *(addr as *mut TaskBuffer);
buffer.call = Some(message);
system_call_raw();
buffer.call.take().unwrap()
}
} | 339 |
fn fist_4() {
run_test(&Instruction { mnemonic: Mnemonic::FIST, operand1: Some(IndirectDisplaced(BX, 1177, Some(OperandSize::Word), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[223, 151, 153, 4], OperandSize:... | 340 |
fn post_order_dfs(
allocs: &mut Allocs,
dfg: &ir::DataFlowGraph,
val: ir::Value,
should_trace: impl Fn(ir::Value) -> bool,
mut visit: impl FnMut(&mut Allocs, ir::Value),
) {
allocs.dfs_stack.push(StackEntry::Trace(val));
while let Some(entry) = allocs.dfs_stack.pop() {
match entry {... | 341 |
pub(crate) fn lock() -> Result<(), ErrorKind> {
let mut count = 1;
loop {
if let Ok(true) = LOCK.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed) {
break;
}
if count > LOCK_TIMEOUT {
return Err(ErrorKind::TimedOut);
}
cpu_rela... | 342 |
fn run_candle(
settings: &Settings,
wix_toolset_path: &Path,
build_path: &Path,
wxs_file_name: &str,
) -> crate::Result<()> {
let arch = match settings.binary_arch() {
"x86_64" => "x64",
"x86" => "x86",
target => {
return Err(crate::Error::ArchError(format!(
"unsupported target: {}",... | 343 |
fn to_rules(line: &str) -> Vec<(Matrix<bool>, Matrix<bool>)> { // todo can I use a fixed-size array? it messes with flat_map below
let (left, right) = line.split(" => ").next_tuple().unwrap();
let pat = to_matrix(left);
let result = to_matrix(right);
vec![
(pat.flipped_lr(), result.clone()),
... | 344 |
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
}
} | 345 |
fn lz_string_utf_16() {
compression_tests(
|s| ByteString::from(lz_str::compress_to_utf16(s)),
|s| {
lz_str::decompress_from_utf16(&s.to_utf8_string().expect("Valid UTF16 String"))
.map(ByteString::from)
},
false,
);
} | 346 |
fn main() {
let path = "input";
let input = File::open(path).unwrap();
let buffered = BufReader::new(input);
let mut total_fuel = 0;
for line in buffered.lines() {
let mass: i64 = line.unwrap().parse().unwrap();
total_fuel += fuel_requirement(mass);
}
println!("Total Fuel... | 347 |
pub fn challenge_12() {
println!("TODO");
} | 348 |
fn curiosity() -> Curiosity {
Curiosity::create(
[
"SELECT DISTINCT ?s WHERE { GRAPH ?g { ?s ?p ?o } }",
"SELECT DISTINCT ?p WHERE { GRAPH ?g { ?s ?p ?o } }",
"SELECT DISTINCT ?o WHERE { GRAPH ?g { ?s ?p ?o } }",
"SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o... | 349 |
fn list_migration_directories_with_an_empty_migrations_folder_works(api: TestApi) {
let migrations_directory = api.create_migrations_directory();
api.list_migration_directories(&migrations_directory)
.send()
.assert_listed_directories(&[]);
} | 350 |
pub unsafe fn set_thread_name(name: &CStr) -> io::Result<()> {
imp::syscalls::tls::set_thread_name(name)
} | 351 |
pub fn set_working_folder(working_folder: String) -> Result<(), ()> {
unsafe {
WORKING_FOLDER = working_folder;
}
Ok(())
} | 352 |
pub extern "x86-interrupt" fn stack_segment_fault() { CommonExceptionHandler(12); } | 353 |
fn main() {
let input = include_str!("day_15.txt");
let initial_state = Cavern::parse(input);
let total_start_time = Instant::now();
let initial_elves = initial_state.elves().count();
let chunk_size: isize = 8;
let mut winning_outcomes = (0..).filter_map(|chunk| {
let chunk_outcomes:... | 354 |
fn fixup(s: String) -> String {
if [
"as", "break", "const", "continue", "crate", "dyn", "else", "enum", "extern", "false",
"fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub",
"ref", "return", "Self", "static", "struct", "super", "trait", "true", "type", "un... | 355 |
fn item_named_query() {
let dir = TestDir::new("sit", "named_query");
dir.cmd()
.arg("init")
.expect_success();
dir.create_file(".sit/reducers/test.js",r#"
module.exports = function(state, record) {
return Object.assign(state, {value: "hello"});
}
"#);
let id = String... | 356 |
fn test_reduce() {
assert_eq!(reduce("dabAcCaCBAcCcaDA"), "dabAaCBAcaDA");
assert_eq!(reduce("dabAaCBAcaDA"), "dabCBAcaDA");
assert_eq!(reduce("dabCBAcaDA"), "dabCBAcaDA");
} | 357 |
fn generate_package_guid(settings: &Settings) -> Uuid {
generate_guid(settings.bundle_identifier().as_bytes())
} | 358 |
fn run_with_config(config: Config) {
let mut simulation =
SimulationConfig::new_from_config(config).create_simulation(Box::new(rand::thread_rng()));
println!("iter\tbest_i\tbest_fit\tns_current\tns_total");
let max_iterations = 100;
loop {
simulation.print_statistics();
if sim... | 359 |
pub fn stp_op(inputs: OpInputs) -> EmulatorResult<()> {
// Reads a value from the PSPACE, writing it into core memory
//
// LDP and STP are not defined in any ICWS standard. This implementation
// is based on pMARS's behavior.
let a = inputs.regs.a;
let b = inputs.regs.b;
let source_value =... | 360 |
fn regular_enum_to_tokens<T: self::enum_variant::Variant>(
tokens: &mut TokenStream,
container_rules: &Option<SerdeContainer>,
enum_variant_features: &Vec<Feature>,
get_variants_tokens_vec: impl FnOnce() -> Vec<T>,
) {
let enum_values = get_variants_tokens_vec();
tokens.extend(match container_r... | 361 |
fn process_value(iof: IntOrFloat) {
unsafe {
match iof {
IntOrFloat {i: 30} => println!("meaning of life value"),
IntOrFloat {f} => println!("f = {}", f)
}
}
} | 362 |
pub unsafe fn exit_thread(status: i32) -> ! {
imp::syscalls::tls::exit_thread(status)
} | 363 |
fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> {
do_extract_comment_blocks(text, false)
} | 364 |
pub fn delete_project_confirmation(dir: StorageDir, search_terms:&[&str]) -> Result<()> {
let luigi = try!(setup_luigi());
for project in try!(luigi.search_projects_any(dir, search_terms)) {
try!(project.delete_project_dir_if(
|| util::really(&format!("you want me to delete {:?} [y/N]", ... | 365 |
fn config_linker() {
let lib_name = match get_platform() {
Platform::Mac => return, // CEF_PATH is not necessarily needed for Mac
Platform::Windows => "libcef",
Platform::Linux => "cef",
};
// Tell the linker the lib name and the path
println!("cargo:rustc-link-lib={}", lib_name... | 366 |
fn main() {
if env::args().len() != 2 {
panic!("Incorrect number of arguments provided\n");
}
let input = BufReader::new(File::open(env::args().nth(1).unwrap()).unwrap());
let mut cols: Vec<BTreeMap<char, i32>> = vec![];
for line in input.lines() {
for (i, c) in line.unwrap().char... | 367 |
fn write_marker<W>(wr: &mut W, marker: Marker) -> Result<(), MarkerWriteError>
where W: Write
{
wr.write_u8(marker.to_u8()).map_err(From::from)
} | 368 |
pub fn smart_to_words(num: usize) -> Words {
let chap = num - 1;
let word_file = File::open(&format!("word/word_smart/word{}.txt", chap))
.expect(&format!("Can't open word{}.txt", chap));
let mean_file = File::open(&format!("word/word_smart/mean{}.txt", chap))
.expect(&format!("Can't open me... | 369 |
fn run_diagnostic_contains_fuzz_dir() {
let (fuzz_dir, mut project_builder) = project_with_fuzz_dir("run_with_crash", None);
let project = project_builder
.with_fuzz()
.fuzz_target(
"yes_crash",
r#"
#![no_main]
use libfuzzer_sys::fuzz_targe... | 370 |
pub fn initialize_logs() -> Result<()> {
// In Release Builds, initiallize the logger, so we get messages in the terminal and recorded to disk.
if !cfg!(debug_assertions) {
CrashReport::init()?;
CombinedLogger::init(
vec![
TermLogger::new(LevelFilter::Info, simplelog... | 371 |
fn write_record_sequence<W>(
writer: &mut W,
sequence: &Sequence,
line_bases: usize,
) -> io::Result<()>
where
W: Write,
{
for bases in sequence.as_ref().chunks(line_bases) {
writer.write_all(bases)?;
writeln!(writer)?;
}
Ok(())
} | 372 |
pub fn challenge_11() {
let mut file = File::open("data/11.txt").unwrap();
let mut all_file = String::new();
file.read_to_string(&mut all_file).unwrap();
let data = base64::decode(&all_file).unwrap();
let it_data = crypto::encryption_oracle(data.clone());
if crypto::is_ecb(it_data) {
pr... | 373 |
pub extern "x86-interrupt" fn invalid_tss() { CommonExceptionHandler(10); } | 374 |
fn unsigned() {
let value = Unsigned::One;
assert!(value.0 == 0x001u32);
let value = Unsigned::Two;
assert!(value.0 == 0x010u32);
let value = Unsigned::Three;
assert!(value.0 == 0x100u32);
let value: Unsigned = 0x010u32.into();
assert!(value == Unsigned::Two);
let value = Unsigne... | 375 |
pub extern "x86-interrupt" fn invalid_opcode() { CommonExceptionHandler( 6); } | 376 |
fn kxord_2() {
run_test(&Instruction { mnemonic: Mnemonic::KXORD, operand1: Some(Direct(K3)), operand2: Some(Direct(K4)), operand3: Some(Direct(K1)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 221, 71, 217], OperandSize::Qword)
} | 377 |
fn build_prompt() -> String {
let prompt = "β>";
env::current_dir().unwrap().to_string_lossy().to_string() + prompt
} | 378 |
pub fn jmn_op(inputs: OpInputs) -> EmulatorResult<()> {
// JMN tests the B-value to determine if it is zero. If the B-value is not
// zero, the sum of the program counter and the A-pointer is queued.
// Otherwise, the next instruction is queued (PC + 1). JMN.I functions as
// JMN.F would, i.e. it jump... | 379 |
pub fn login(path: &str, password: &str) -> Result<User> {
AUTH.login(path, password)
} | 380 |
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... | 381 |
fn uri_to_path(uri: &str) -> WorkspaceResult<PathBuf> {
let url = Url::parse(uri).map_err(|_| WorkspaceError("invalid URI"))?;
if url.scheme() != "file" {
return Err(WorkspaceError("non-file URI"));
}
if let Ok(path) = url.to_file_path() {
return Ok(path);
}
#[cfg(windows)]
... | 382 |
pub extern "x86-interrupt" fn debug() { CommonExceptionHandler( 1); } | 383 |
fn figure5_random() {
// Chance of missing the bug is (1 - 2^-20)^100 ~= 99.99%, so this should not trip the assert
check_random(figure5, 100);
} | 384 |
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,
... | 385 |
fn kill_things(
ecs: &mut World,
commands: &mut CommandBuffer,
dead_entities: Vec<Entity>,
splatter: &mut Option<RGB>,
) {
dead_entities.iter().for_each(|entity| {
crate::stats::record_death();
let mut was_decor = false;
let mut was_player = false;
if let Ok(mut er) =... | 386 |
fn print_node(prefix: &str, node: &IRNode) {
let next_prefix = get_next_prefix(prefix);
match node {
&IRNode::Assignment(ref name, ref exp) => {
println!("{}Assignment-'{}':", prefix, name);
print_expression(&next_prefix, exp);
}
&IRNode::DeclareVariable(ref name,... | 387 |
pub fn causet_partitioner_scan_column_as_bool(
context: Box<CausetPartitionerContext>,
column_name: &[u8],
column_value: &[u8],
) -> Box<CausetPartitionerContext> {
context
} | 388 |
pub fn crate_incoherent_impls(tcx: TyCtxt<'_>, simp: SimplifiedType) -> &[DefId] {
let crate_map = tcx.crate_inherent_impls(());
tcx.arena.alloc_from_iter(
crate_map.incoherent_impls.get(&simp).unwrap_or(&Vec::new()).iter().map(|d| d.to_def_id()),
)
} | 389 |
pub fn simple_with_projects<F>(dir:StorageDir, search_terms:&[&str], f:F)
where F:Fn(&Project)
{
match with_projects(dir, search_terms, |p| {f(p);Ok(())}){
Ok(_) => {},
Err(e) => error!("{}",e)
}
} | 390 |
pub async fn accept_hdr_async_with_config<S, C>(
stream: S,
callback: C,
config: Option<WebSocketConfig>,
) -> Result<WebSocketStream<TokioAdapter<S>>, Error>
where
S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin,
C: Callback + Unpin,
{
crate::accept_hdr_async_with_config(TokioAdapter(st... | 391 |
fn defaults_are_preserved_when_generating_data_model_from_a_schema() {
let ref_data_model = Datamodel {
models: vec![Model {
database_name: None,
name: "Table1".to_string(),
documentation: None,
is_embedded: false,
is_commented_out: false,
... | 392 |
fn main() -> Result<(), std::io::Error> {
let mut token = std::ptr::null_mut();
let r = unsafe {OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &mut token) };
if r == 0 {
return Err(std::io::Error::last_os_error());
}
set_privilege(token, SE_RESTORE_NAME)?;
set_privilege(... | 393 |
fn execve_wrapper(args: Vec<&str>) {
let path = CString::new(find_realpath(&args[0])).unwrap();
let mut cargs = Vec::<CString>::new();
for arg in args {
cargs.push(CString::new(arg).unwrap());
}
let envs: Vec<CString> = env::vars()
.map(|(k, v)| CString::new(format!("{}={}", k, v))... | 394 |
pub fn assert_unary_params<D: Display>(name: D, actual: usize) -> Result<()> {
if actual != 1 {
return Err(ErrorCode::NumberArgumentsNotMatch(format!(
"{} expect to have single parameters, but got {}",
name, actual
)));
}
Ok(())
} | 395 |
fn is_collapse_string_parts(parts: &Node) -> bool {
true
} | 396 |
pub extern "x86-interrupt" fn parallel_1() { CommonInterruptHandler(39); } | 397 |
fn default_handler(irqn: i16) {
panic!("Unhandled exception (IRQn = {})", irqn);
} | 398 |
fn main()
{
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
eprintln!("Syntax: {} <filename>", args[0]);
return;
}
let path = Path::new(&args[1]);
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!("... | 399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.