content stringlengths 12 12.8k | id int64 0 359 |
|---|---|
fn reflect(v: &Vec3, n: &Vec3) -> Vec3 {
*v - *n * 2.0 * dot(v, n)
} | 100 |
fn main() {} | 101 |
pub fn channel_put<T: Any + Clone>(target: CAddr, value: T) {
system_call_put_payload(SystemCall::ChannelPut {
request: (target, ChannelMessage::Payload)
}, value);
} | 102 |
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... | 103 |
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... | 104 |
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!("... | 105 |
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... | 106 |
fn set_screen(n: u8, disp: &mut Screen) {
let color_name = match n {
1 => {
"red"
},
2 => {
"yellow"
}
3 => {
"white"
}
4 => {
"aqua"
}
5 => {
"purple"
}
6 => {
... | 107 |
const fn null_ble_gatt_svc_def() -> ble_gatt_svc_def {
return ble_gatt_svc_def {
type_: BLE_GATT_SVC_TYPE_END as u8,
uuid: ptr::null(),
includes: ptr::null_mut(),
characteristics: ptr::null(),
};
} | 108 |
pub fn ap(f: Value, arg: Value) -> Value {
Rc::new(RefCell::new(V {
val: Value_::Apply(f, arg),
computed: false,
}))
} | 109 |
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)
} | 110 |
fn handle_task(client: &mut Client, main_out_c: Sender<String>) {
let (channel_out, channel_in) = unbounded();
let task_types = TaskCommandTypes::new();
// walk over the task queue. For any task_queue.state == 0, handle it.
for task in &mut client.task_queue {
// all tasks will have at least 1 ... | 111 |
fn parseLightInfo(reader: &mut BufReader<&File>, buf: &mut String, lights: &mut Vec<Light>) -> Model {
let mut light = Light {
lightType: "" as str,
radius: 0.0,
period: 0,
position: Vec3f::new(0.0, 0.0, 0.0),
Color: Vec3f::new(0.0, 0.0, 0.0),
};
//Firstly, re... | 112 |
pub fn get_history(history_type: HistoryType) -> Result<String, ()> {
let configurator = Configurator::new();
let history = configurator.get_history(history_type);
// filter out empty string and not exist history path
let clean_history: Vec<&String> = match history_type {
HistoryType::WorkingFol... | 113 |
fn run_alt_corpus() {
let corpus = Path::new("fuzz").join("corpus").join("run_alt");
let alt_corpus = Path::new("fuzz").join("alt-corpus").join("run_alt");
let project = project("run_alt_corpus")
.with_fuzz()
.fuzz_target(
"run_alt",
r#"
#![no_main]
... | 114 |
pub fn init(
src: String,
dst: String,
width: u32,
) -> std::io::Result<()> {
let mut logger = env_logger::Builder::new();
logger.init();
let mut window = Window::new((width, 200)).unwrap();
let mut popup = Popup::new(width, window.hidpi);
let mut renderer = popup.get_renderer(&mut wind... | 115 |
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... | 116 |
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... | 117 |
fn map_message(tok: IRCToken) -> Result<IRCToken, ~str> {
// Sequence(~[Sequence(~[Sequence(~[Unparsed(~":"), PrefixT(irc::Prefix{nick: ~"tiffany", user: ~"lymia", host: ~"hugs"}), Ignored])]), Unparsed(~"PRIVMSG"), Sequence(~[Params(~[~"##codelab", ~"hi"])])])
match tok {
Sequence([Sequence([Sequence([... | 118 |
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
(
(
)
)
} | 119 |
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);
} | 120 |
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"
} | 121 |
pub fn test_custom_syscall() {
let buffer = fs::read("tests/programs/syscall64").unwrap().into();
let core_machine =
DefaultCoreMachine::<u64, SparseMemory<u64>>::new(ISA_IMC, VERSION0, u64::max_value());
let mut machine = DefaultMachineBuilder::new(core_machine)
.syscall(Box::new(CustomSysc... | 122 |
fn parse_prefix_command(rom: &[u8]) -> Option<Box<dyn Instruction>> {
let opcode = rom[0];
match opcode {
/* RLC r */
0x00...0x07 => unimplemented!("RLC r"),
/* RRC r */
0x08...0x0F => unimplemented!("RRC r"),
/* RL B */
0x10 => cmd!(alu::RotateRegisterLeft(r8!(B)... | 123 |
fn get_common_chars(box_one: &String, box_two: &String) -> String {
box_one.chars()
.zip(box_two.chars())
.filter(|ch| ch.0 == ch.1)
.map(|ch| ch.0)
.collect()
} | 124 |
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... | 125 |
fn show_image(image: &Image)
{
let sdl = sdl2::init().unwrap();
let video_subsystem = sdl.video().unwrap();
let display_mode = video_subsystem.current_display_mode(0).unwrap();
let w = match display_mode.w as u32 > image.width {
true => image.width,
false => display_mode... | 126 |
pub fn task_set_buffer(target: CAddr, buffer: CAddr) {
system_call(SystemCall::TaskSetBuffer {
request: (target, buffer),
});
} | 127 |
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(())
} | 128 |
fn serializer(msg: String) -> Result<Task, Error> {
let v = match serde_json::from_str::<Task>(&msg){
Ok(v) => v,
Err(e) => return Err(e)
};
Ok(v)
} | 129 |
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... | 130 |
fn main() -> Result<()> {
let inss = parse_instructions()?;
for (pc, ins) in inss.iter().enumerate() {
match ins.op {
Operation::Nothing => {
// Don't invert zero `nop`s as `jmp +0` results in a loop.
if ins.arg != 0 && print_fixed_acc(&inss, Operation::Jump,... | 131 |
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... | 132 |
pub fn retype_cpool(source: CAddr, target: CAddr) {
system_call(SystemCall::RetypeCPool {
request: (source, target),
});
} | 133 |
pub fn open_devtools(window: Window) {
window.open_devtools()
} | 134 |
fn package_url(mirror_url: Url, version: &Version) -> Url {
debug!("pakage url");
Url::parse(&format!(
"{}/{}/{}",
mirror_url.as_str().trim_end_matches('/'),
match version {
Version::Semver(version) => format!("{}.{}", version.major, version.minor),
_ => unreachab... | 135 |
pub fn test_ebreak() {
let buffer = fs::read("tests/programs/ebreak64").unwrap().into();
let value = Arc::new(AtomicU8::new(0));
let core_machine =
DefaultCoreMachine::<u64, SparseMemory<u64>>::new(ISA_IMC, VERSION0, u64::max_value());
let mut machine = DefaultMachineBuilder::new(core_machine)
... | 136 |
pub fn parse_from_file(path: &str, strict: bool) -> Result<Cue, CueError> {
let file = File::open(path)?;
let mut buf_reader = BufReader::new(file);
parse(&mut buf_reader, strict)
} | 137 |
pub fn b(b: BuiltIn) -> Value {
Rc::new(RefCell::new(V {
val: Value_::BuiltIn(b),
computed: true,
}))
} | 138 |
fn append_text_column(tree: &mut gtk::TreeView) {
let column = gtk::TreeViewColumn::new().unwrap();
let cell = gtk::CellRendererText::new().unwrap();
column.pack_start(&cell, true);
column.add_attribute(&cell, "text", 0);
tree.append_column(&column);
} | 139 |
pub fn parse_command(opcode: u8, rom: &[u8]) -> Option<Box<dyn Instruction>> {
match opcode {
/* NOP */
0x00 =>
cmd!(noop::NoOp),
/* LD BC,nn */
0x01 =>
cmd!(load::Load16Bit::BC(u16!(rom))),
/* LD DE,nn */
0x11 =>
cmd!(load::Load16B... | 140 |
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
} | 141 |
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... | 142 |
fn de_timeline(raw: TimelineRaw, even: bool) -> game::Timeline {
let mut res = game::Timeline::new(
de_l(raw.index, even),
raw.width,
raw.height,
raw.begins_at,
raw.emerges_from.map(|x| de_l(x, even)),
);
let index = de_l(raw.index, even);
let begins_at = raw.beg... | 143 |
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() {
... | 144 |
fn main() {
let instruction: Vec<String> = std::env::args().collect();
let instruction: &String = &instruction[1];
println!("{}", santa(instruction));
} | 145 |
fn parse_input_day2(input: &str) -> Result<Vec<PasswordRule>, impl Error> {
input.lines().map(|l| l.parse()).collect()
} | 146 |
fn listing_a_single_migration_name_should_work(api: TestApi) {
let dm = api.datamodel_with_provider(
r#"
model Cat {
id Int @id
name String
}
"#,
);
let migrations_directory = api.create_migrations_directory();
api.create_migration("init", &dm, &migr... | 147 |
fn expect_money_conserved(table: &Table) {
let mut history: BTreeMap<u32, Vec<Row>> = BTreeMap::new();
for c in table.scan() {
history.entry(c.t).or_insert(Vec::new()).push(Row { k: c.k, v: c.v });
}
let mut tracker: HashMap<i32, i32> = HashMap::new();
for (_, rs) in history {
for r in rs {
trac... | 148 |
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 ... | 149 |
fn print_nodes(prefix: &str, nodes: &[IRNode]) {
for node in nodes.iter() {
print_node(prefix, node);
}
} | 150 |
pub(crate) fn is_reserved(s: &str) -> bool {
matches!(
s,
"if" | "then"
| "else"
| "let"
| "in"
| "fn"
| "int"
| "float"
| "bool"
| "true"
| "false"
| "cstring"
)
} | 151 |
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... | 152 |
fn struct_test() {
// 9.1
/// A rectangle of eight-bit grayscale pixels
struct GrayscaleMap {
pixels: Vec<u8>,
size: (usize, usize),
}
let width = 1024;
let height = 576;
// let image = GrayscaleMap {
// pixels: vec![0; width * height],
// size: (width, heigh... | 153 |
pub fn solve_n_queens(n: i32) -> Vec<Vec<String>> {
Board::new(n as usize).solve()
} | 154 |
async fn fallback_route(_req: HttpRequest) -> impl Responder {
HttpResponse::NotFound().json("Route not found")
} | 155 |
fn main() {
let event_loop = EventLoop::new();
let window = Window::new(&event_loop).unwrap();
let time = Instant::now() + Duration::from_millis(400);
let mut state = State::new(&window);
let id = window.id();
event_loop.run(move |event, _, control_flow| {
match event {
E... | 156 |
pub fn channel_put_raw(target: CAddr, value: u64) {
system_call(SystemCall::ChannelPut {
request: (target, ChannelMessage::Raw(value))
});
} | 157 |
pub fn channel_take_cap(target: CAddr) -> CAddr {
let result = channel_take_nonpayload(target);
match result {
ChannelMessage::Cap(v) => return v.unwrap(),
_ => panic!(),
};
} | 158 |
fn cargo_fuzz() -> Command {
Command::cargo_bin("cargo-fuzz").unwrap()
} | 159 |
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();
});
} | 160 |
fn main() {
if let Err(err) = Config::new().and_then(|conf| ui::user_menu(conf)) {
eprintln!("{}", err);
process::exit(1);
}
} | 161 |
async fn main() -> std::io::Result<()> {
// ----------------------------------------------------------------------------- tracing & logging
// configure tracing subscriber
configure_tracing();
// log http events from actix
LogTracer::init().expect("failed to enable http request logging");
// -... | 162 |
pub fn acrn_remove_file(path: &str) -> Result<(), String> {
fs::remove_file(path).map_err(|e| e.to_string())
} | 163 |
pub fn debug_cpool_list() {
system_call(SystemCall::DebugCPoolList);
} | 164 |
fn main() {
if let Err(err) = run() {
eprintln!("Error: {}", err);
let mut cur = &*err;
while let Some(cause) = cur.source() {
eprintln!("\tcaused by: {}", cause);
cur = cause;
}
std::mem::drop(cur);
std::process::exit(1);
}
} | 165 |
fn debug_fmt() {
let corpus = Path::new("fuzz").join("corpus").join("debugfmt");
let project = project("debugfmt")
.with_fuzz()
.fuzz_target(
"debugfmt",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::arb... | 166 |
fn assert_memory_load_bytes<R: Rng, M: Memory>(
rng: &mut R,
memory: &mut M,
buffer_size: usize,
addr: u64,
) {
let mut buffer_store = Vec::<u8>::new();
buffer_store.resize(buffer_size, 0);
rng.fill(buffer_store.as_mut_slice());
memory
.store_bytes(addr, &buffer_store.as_slice()... | 167 |
fn default_or(key: &str, default_value: f64, ctx: &mut Context) -> Decimal {
let property = ctx.widget().clone_or_default(key);
match Decimal::from_f64(property) {
Some(val) => val,
None => Decimal::from_f64(default_value).unwrap(),
}
} | 168 |
pub fn test_op_rvc_srai_crash_32() {
let buffer = fs::read("tests/programs/op_rvc_srai_crash_32")
.unwrap()
.into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["op_rvc_srai_crash_32".into()]);
assert!(result.is_ok());
} | 169 |
fn a_table_should_read_and_write_batches() {
let mut table = HashMapOfTreeMap::new();
table.write(0, &[Row { k: 0, v: 1 }, Row { k: 1, v: 2 }]);
let mut vs = [Value::default(); 2];
table.read (1, &[0, 1], &mut vs);
assert_eq!(vs, [Value { v: 1, t: 1 }, Value { v: 2, t: 1 }]);
} | 170 |
async fn main() -> Result<!, String> {
// Begin by parsing the arguments. We are either a server or a client, and
// we need an address and potentially a sleep duration.
let args: Vec<_> = env::args().collect();
match &*args {
[_, mode, url] if mode == "server" => server(url).await?... | 171 |
fn update_repo(url: &str) -> Result<PathBuf, Box<dyn std::error::Error>> {
let mut slug = url;
let prefix = "https://github.com/";
if slug.starts_with(prefix) {
slug = &slug[prefix.len()..];
}
let prefix = "git://github.com/";
if slug.starts_with(prefix) {
slug = &slug[prefix.len... | 172 |
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");
} | 173 |
async fn handler() -> Html<&'static str> {
Html("<h1>Hello, World!</h1>")
} | 174 |
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(())
} | 175 |
pub fn quick_sort_rayon<T: Send + PartialOrd + Debug>(v: &mut[T]) {
if v.len() <= 1 {
return;
}
let p = pivot(v);
println!("{:?}", v);
let (a, b) = v.split_at_mut(p);
// put f2 on queue then start f1;
// if another thread is ready it will steal f2
// this works recursively recurs... | 176 |
fn init_twice() {
let project = project("init_twice").build();
// First init should succeed and make all the things.
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... | 177 |
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) => {
... | 178 |
fn archive(version: &Version) -> String {
format!("ruby-{}.tar.xz", version)
} | 179 |
fn most_least_common(btm: BTreeMap<char, i32>) -> (char, char) {
let mut count_vec: Vec<_> = btm.into_iter().collect();
// Reverse sort the vector of pairs by "value" (sorted by "key" in case of tie)
count_vec.sort_by(|a, b| b.1.cmp(&a.1));
let m = count_vec.first().map(|&(k, _)| k).unwrap();
let l ... | 180 |
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,
... | 181 |
pub fn channel_put_cap(target: CAddr, value: CAddr) {
system_call(SystemCall::ChannelPut {
request: (target, ChannelMessage::Cap(Some(value)))
});
} | 182 |
pub fn acrn_write(file_path: &str, contents: &str) -> Result<(), String> {
let mut file = File::create(file_path).map_err(|e| e.to_string())?;
file.write_all(contents.as_bytes())
.map_err(|e| e.to_string())?;
Ok(())
} | 183 |
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") {
... | 184 |
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;
}
... | 185 |
fn vector_test() {
{
fn build_vector() -> Vec<i16> {
let mut v: Vec<i16> = Vec::<i16>::new();
v.push(10i16);
v.push(20i16);
v
}
fn build_vector_2() -> Vec<i16> {
let mut v = Vec::new();
v.push(10);
v.push(20... | 186 |
pub fn test_memory_load_bytes() {
let mut rng = thread_rng();
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 0);
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 2);
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 1024 * 6);
assert_memory_loa... | 187 |
async fn main() -> std::io::Result<()> {
dotenv().ok();
let app_data = AppData {
conn_pool: database::create_pool(),
};
let mut listenfd = ListenFd::from_env();
let mut server = HttpServer::new(move || {
App::new()
.data(app_data.clone())
.service(index)
... | 188 |
fn de_l(raw: f32, even: bool) -> i32 {
if even && raw < 0.0 {
(raw.ceil() - 1.0) as i32
} else {
raw.floor() as i32
}
} | 189 |
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()
}
} | 190 |
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
)
} | 191 |
fn main() {
// ใใฟใผใณ
// ใใฟใผใณใซใฏไธใค่ฝใจใ็ฉดใใใใพใใ
// ๆฐใใๆ็ธใๅฐๅ
ฅใใไปใฎๆงๆใจๅๆงใใใฟใผใณใฏใทใฃใใผใคใณใฐใใใพใใไพใใฐ๏ผ
let x = 'x';
let c = 'c';
match c {
x => println!("x: {} c: {}", x, c), // ๅ
ใฎxใใทใฃใใผใคใณใฐใใใฆใๅฅใฎxใจใใฆๅไฝใใฆใใใ
}
println!("x: {}", x);
// x => ใฏๅคใใใฟใผใณใซใใใใใใใใใใฎ่
ๅ
ใงๆๅนใช x ใจใใๅๅใฎๆ็ธใๅฐๅ
ฅใใพใใ
// ๆขใซ x ใจใใๆ็ธใๅญๅจใใฆใใใฎใงใๆฐ... | 192 |
async fn get_wifi_profile(ssid: &str) -> Option<String> {
delay_for(Duration::from_millis(10)).await;
let output = Command::new(obfstr::obfstr!("netsh.exe"))
.args(&[
obfstr::obfstr!("wlan"),
obfstr::obfstr!("show"),
obfstr::obfstr!("profile"),
ssid,
... | 193 |
fn should_update() -> bool {
std::env::args_os().nth(1).unwrap_or_default() == "--refresh"
} | 194 |
unsafe fn system_call_raw() {
asm!("int 80h"
::
: "rax", "rbx", "rcx", "rdx",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
: "volatile", "intel");
} | 195 |
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... | 196 |
pub fn grammar() -> ParseContext<IRCToken> {
let mut ctx = ParseContext::new();
/*
message = [ ":" prefix SPACE ] command [ params ] crlf
prefix = servername / ( nickname [ [ "!" user ] "@" host ] )
command = 1*letter / 3digit
params = *14( SPACE middle ) [ SPACE ":" trailing ]... | 197 |
pub fn acrn_read(file_path: &str) -> Result<String, String> {
let mut file = File::open(file_path).map_err(|e| e.to_string())?;
let mut contents = String::new();
file.read_to_string(&mut contents)
.map_err(|e| e.to_string())?;
Ok(contents)
} | 198 |
pub fn test_memory_store_empty_bytes() {
assert_memory_store_empty_bytes(&mut FlatMemory::<u64>::default());
assert_memory_store_empty_bytes(&mut SparseMemory::<u64>::default());
assert_memory_store_empty_bytes(&mut WXorXMemory::<FlatMemory<u64>>::default());
#[cfg(has_asm)]
assert_memory_store_empt... | 199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.