content stringlengths 12 392k | id int64 0 1.08k |
|---|---|
fn main() {
func_2();
} | 400 |
pub fn spec() -> Result<()> {
use project::spec::*;
let luigi = try!(setup_luigi());
//let projects = super::execute(||luigi.open_projects(StorageDir::All));
let projects = try!(luigi.open_projects(StorageDir::Working));
for project in projects{
info!("{}", project.dir().display());
... | 401 |
pub fn write_bool<W>(wr: &mut W, val: bool) -> Result<(), FixedValueWriteError>
where W: Write
{
match val {
true => write_fixval(wr, Marker::True),
false => write_fixval(wr, Marker::False)
}
} | 402 |
pub fn write_i64<W>(wr: &mut W, val: i64) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::I64));
write_data_i64(wr, val)
} | 403 |
pub fn benchmark(c: &mut Criterion, mode: Mode) {
match mode {
Mode::MetricsOff => {
disable_metrics();
disable_metrics_tracing_integration();
}
Mode::MetricsNoTracingIntegration => {
disable_metrics_tracing_integration();
}
Mode::MetricsOn... | 404 |
fn lz_string_base_64() {
compression_tests(
|s| lz_str::compress_to_base64(s).into(),
|s| {
lz_str::decompress_from_base64(&s.to_utf8_string().expect("Valid UTF16 String"))
.map(ByteString::from)
},
false,
);
} | 405 |
pub fn make_buffer_with<T, F: FnMut () -> T> (len: usize, mut f: F) -> Box<[T]> {
make_buffer_with_indexed(len, move |_| f())
} | 406 |
pub fn get_and_extract_wix(path: &Path) -> crate::Result<()> {
common::print_info("Verifying wix package")?;
let data = download_and_verify(WIX_URL, WIX_SHA256)?;
common::print_info("extracting WIX")?;
extract_zip(&data, path)
} | 407 |
fn main() {
const A_ID: TypeId = TypeId::of::<A>();
//~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn
} | 408 |
fn map_simple() -> Result<(), Box<dyn Error>> {
let mut cmd = Command::cargo_bin("mrf")?;
cmd.arg("map").arg("test-001").arg("{}{=_}{}");
cmd.assert()
.success()
.stdout(predicate::eq("test-001\0test_001\0"));
Ok(())
} | 409 |
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")
... | 410 |
pub unsafe fn arm_set_tls(data: *mut c_void) -> io::Result<()> {
imp::syscalls::tls::arm_set_tls(data)
} | 411 |
fn fuzzy_score(
choice_ch: char,
choice_idx: usize,
choice_prev_ch: char,
pat_ch: char,
pat_idx: usize,
_pat_prev_ch: char,
) -> i64 {
let mut score = BONUS_MATCHED;
let choice_prev_ch_type = char_type_of(choice_prev_ch);
let choice_role = char_role(choice_prev_ch, choice_ch);
... | 412 |
fn read_vector<T>() -> Vec<T>
where
T: std::str::FromStr,
T::Err: std::fmt::Debug,
{
let mut buf = String::with_capacity(100);
stdin().read_line(&mut buf).unwrap();
return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
} | 413 |
fn state_from_snapshot<F>(
snapshot: ::fidl::InterfacePtr<PageSnapshot_Client>,
key: Vec<u8>,
done: F,
) where
F: Send + FnOnce(Result<Option<Engine>, ()>) + 'static,
{
assert_eq!(PageSnapshot_Metadata::VERSION, snapshot.version);
let mut snapshot_proxy = PageSnapshot_new_Proxy(snapshot.inner);
... | 414 |
fn
default
(
)
-
>
AtomicCell
<
T
>
{
AtomicCell
:
:
new
(
T
:
:
default
(
)
)
}
}
impl
<
T
>
From
<
T
>
for
AtomicCell
<
T
>
{
#
[
inline
]
fn
from
(
val
:
T
)
-
>
AtomicCell
<
T
>
{
AtomicCell
:
:
new
(
val
)
}
}
impl
<
T
:
Copy
+
fmt
:
:
Debug
>
fmt
:
:
Debug
for
AtomicCell
<
T
>
{
fn
fmt
(
&
self
f
:
&
mut
fmt
:
:
... | 415 |
fn run_light(
wix_toolset_path: &Path,
build_path: &Path,
wixobjs: &[&str],
output_path: &Path,
) -> crate::Result<PathBuf> {
let light_exe = wix_toolset_path.join("light.exe");
let mut args: Vec<String> = vec![
"-ext".to_string(),
"WixUIExtension".to_string(),
"-o".to_string(),
output_path... | 416 |
pub async fn accept_async_with_config<S>(
stream: S,
config: Option<WebSocketConfig>,
) -> Result<WebSocketStream<TokioAdapter<S>>, Error>
where
S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin,
{
accept_hdr_async_with_config(stream, NoCallback, config).await
} | 417 |
fn is_permutation(input1: &str, input2: &str) -> bool {
if input1.len() != input2.len() {
return false;
}
let count_map_input1 = count_char(input1);
let count_map_input2 = count_char(input2);
if count_map_input1 == count_map_input2 {
return true;
}
false
} | 418 |
fn openssl_dir() -> Result<String, FrumError> {
#[cfg(target_os = "macos")]
return Ok(String::from_utf8_lossy(
&Command::new("brew")
.arg("--prefix")
.arg("openssl")
.output()
.map_err(FrumError::IoError)?
.stdout,
)
.trim()
.to_str... | 419 |
pub fn accessible(node: Node) -> Node {
println!("building node:accessible, node: {:?}", node);
return match node {
Node::Ident(n_ident_value) => {
// TODO DUMMY
// TODO handle static_env
let node = Node::LVar(n_ident_value);
return node;
}
... | 420 |
pub fn nbt_decode_enum(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let receiver = nbt_decode::NbtDecodeReceiver::from_derive_input(&ast).unwrap();
let result = wrap_use(receiver.ident, "nbtdecode", &receiver);
let mut tokens = quote::Tokens::new();
t... | 421 |
fn main() {
let now = Instant::now();
// This is our data to process.
// We will calculate the sum of all digits via a threaded map-reduce algorithm.
// Each whitespace separated chunk will be handled in a different thread.
//
// TODO: see what happens to the output if you insert spaces!
let d... | 422 |
fn main() {
input! {
n: usize,
s: [String; n],
}
// (ユーザ名, 登録日) のマップを作る
// 降順にして一回だけ走査し、同じ値だった場合は上書きする
let mut map: HashMap<String, usize> = HashMap::new();
for i in (0..n).rev() {
map.insert(s[i].to_string(), i + 1);
}
// 登録日の昇順でソートする
let mut vec = map.into... | 423 |
pub async fn handle_request<T>(
req: Request<T>,
client: &Client,
config: &ServerConfig,
) -> Result<Response<Body>, Error> {
match req.uri().path() {
// JSON API with the status of the network.
"/data" => {
let servers = schema::get_servers(client)
.await?
... | 424 |
pub fn assert_binary_arguments<D: Display>(name: D, actual: usize) -> Result<()> {
if actual != 2 {
return Err(ErrorCode::NumberArgumentsNotMatch(format!(
"{} expect to have two arguments, but got {}",
name, actual
)));
}
Ok(())
} | 425 |
pub fn acrn_create_dir(path: &str, recursive: bool) -> Result<(), String> {
if recursive {
fs::create_dir_all(path).map_err(|e| e.to_string())
} else {
fs::create_dir(path).map_err(|e| e.to_string())
}
} | 426 |
fn inc_14() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(Indirect(SI, Some(OperandSize::Word), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[255, 4], OperandSize::Word)
} | 427 |
pub extern "x86-interrupt" fn ISR15() { CommonExceptionHandler(15); } | 428 |
pub(crate) fn format_path_ref(path: &Path) -> String {
let mut path = path.clone();
// Generics and path arguments are unsupported
if let Some(last_segment) = path.segments.last_mut() {
last_segment.arguments = PathArguments::None;
}
// :: are not officially supported in the spec
// See... | 429 |
fn create_mesh_buffer_verts(
chunk: &Chunk,
device: &wgpu::Device,
queue: &wgpu::Queue,
) -> MeshBufferVerts {
// Calculate total length of buffer e.g. a full chunk of different voxels. This way a new buffer only has to be created when the voxel capacity is changed.
let verts = Mesh::verts(chunk);
... | 430 |
fn part2(_filename: &Path) -> String {
String::from("Start The Blender")
} | 431 |
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
} | 432 |
pub fn count_ones(mut x: u64) -> usize {
x = x - ((x & 0xAAAA_AAAA_AAAA_AAAA) >> 1);
x = (x & 0x3333_3333_3333_3333) + ((x >> 2) & 0x3333_3333_3333_3333);
x = (x + (x >> 4)) & 0x0F0F_0F0F_0F0F_0F0F;
(x.wrapping_mul(L8) >> 56) as usize
} | 433 |
pub fn median_filter_hist_optimized(frame : ImageBuffer<Luma<u8>, Vec<u8>>, kernel_size : usize) -> ImageBuffer<Luma<u8>, Vec<u8>> {
//assert!(kernel_size % 2 == 1, "Kernel size must be odd");
let mut result = ImageBuffer::new(640, 480);
let kernel_offset = ((kernel_size - 1) / 2) as i32;
for i in 0... | 434 |
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... | 435 |
fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
//Read file into a string
let mut string = String::new();
File::open(path).and_then(|mut f| f.read_to_string(&mut string)).map(|_| string)
} | 436 |
fn de_l(raw: f32, even: bool) -> i32 {
if even && raw < 0.0 {
(raw.ceil() - 1.0) as i32
} else {
raw.floor() as i32
}
} | 437 |
fn build_url(host: &str, page: Option<i32>) -> String {
match page {
Some(p) => format!(
"https://api.binaryedge.io/v2/query/domains/subdomain/{}?page={}",
host, p
),
None => format!(
"https://api.binaryedge.io/v2/query/domains/subdomain/{}",
h... | 438 |
pub fn u8_to_u16(b1: u8, b2: u8) -> u16 {
(u16::from(b1) << 8) | u16::from(b2)
} | 439 |
fn
test_string
(
)
-
>
Result
<
(
)
>
{
let
db
=
checked_memory_handle
(
)
?
;
let
s
=
"
hello
world
!
"
;
db
.
execute
(
"
INSERT
INTO
foo
(
t
)
VALUES
(
?
1
)
"
[
s
.
to_owned
(
)
]
)
?
;
let
from
:
String
=
db
.
one_column
(
"
SELECT
t
FROM
foo
"
)
?
;
assert_eq
!
(
from
s
)
;
Ok
(
(
)
)
} | 440 |
fn main() {
let x = 2.0; // f64
println!("x: {}", x);
let y: f32 = 3.0; // f32
println!("y: {}", y);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (x, y, z) = tup;
println!("The value of x is: {}", x);
println!("The value of y is: {}", y);
println!("The value of z is: {}", z);
let a = [1, 2, 3, 4, 5]... | 441 |
fn parse_pbs_job_remaining_time(job_id: &str, data: &str) -> anyhow::Result<Duration> {
let data_json: Value = serde_json::from_str(data)?;
let walltime = parse_hms_duration(
data_json["Jobs"][job_id]["Resource_List"]["walltime"]
.as_str()
.ok_or_else(|| anyhow::anyhow!("Could n... | 442 |
fn binary_decoding_compatibility_tests_mandatory() {
eprintln!("base64 - old encoding");
let base64_encoding_old_decompressed = "During tattooing, ink is injected into the skin, initiating an immune response, and cells called \"macrophages\" move into the area and \"eat up\" the ink. The macrophages carry some ... | 443 |
pub fn encode(ch: char) -> Option<u16> {
match ch as u32 {
0x3000 => Some(0x2121u16),
0x3001 => Some(0x2122u16),
0x3002 => Some(0x2123u16),
0xff0c => Some(0x2124u16),
0xff0e => Some(0x2125u16),
0x30fb => Some(0x2126u16),
0xff1a => Some(0x2127u16),
0xff... | 444 |
fn match_any_qpath(path: &hir::QPath<'_>, paths: &[&[&str]]) -> bool {
paths.iter().any(|candidate| match_qpath(path, candidate))
} | 445 |
fn main() {
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
spawn(
serde_json::to_vec,
|bytes| serde_json::from_slice(bytes),
vec![
(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 3000), ServerActor)
]).unwrap();
} | 446 |
pub fn assignable(node: Node) -> Node {
println!("DEBUGGING node::assignable: {:?}", node);
match node {
Node::Ident(ident) => {
// name, = *node
// @parser.static_env.declare(name)
//
// node.updated(:lVasgn)
// TODO handle appen... | 447 |
pub fn build_wix_app_installer(
settings: &Settings,
wix_toolset_path: &Path,
) -> crate::Result<PathBuf> {
let arch = match settings.binary_arch() {
"x86_64" => "x64",
"x86" => "x86",
target => {
return Err(crate::Error::ArchError(format!(
"unsupported target: {}",
target
... | 448 |
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([... | 449 |
pub fn write_nfix<W>(wr: &mut W, val: i8) -> Result<(), FixedValueWriteError>
where W: Write
{
assert!(-32 <= val && val < 0);
write_fixval(wr, Marker::FixNeg(val))
} | 450 |
fn figure_1c() {
const COUNT: usize = 4usize;
// n=2, k=2*14, d=2, so probability of finding the bug is at least 1/(2*28)
// So probability of hitting the bug in 400 iterations = 1 - (1 - 1/56)^400 > 99.9%
let scheduler = PctScheduler::new(2, 400);
let runner = Runner::new(scheduler, Default::defaul... | 451 |
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... | 452 |
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;
}
... | 453 |
fn roll(die: i32) -> i32 {
let mut rng = rand::thread_rng();
rng.gen_range(1, die)
} | 454 |
fn invoke_rustdoc(
builder: &Builder<'_>,
compiler: Compiler,
target: Interned<String>,
markdown: &str,
) {
let out = builder.doc_out(target);
let path = builder.src.join("src/doc").join(markdown);
let header = builder.src.join("src/doc/redirect.inc");
let footer = builder.src.join("sr... | 455 |
fn build_stripping_dead_code() {
let project = project("build_strip").with_fuzz().build();
// Create some targets.
project
.cargo_fuzz()
.arg("add")
.arg("build_strip_a")
.assert()
.success();
project
.cargo_fuzz()
.arg("build")
.arg("--s... | 456 |
pub fn quick_sort<T: PartialOrd + Debug>(v: &mut [T]) {
if v.len() <= 1 {
return;
}
let p = pivot(v);
println!("{:?}", v);
let (a, b) = v.split_at_mut(p);
quick_sort(a);
quick_sort(&mut b[1..]);
} | 457 |
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)?
... | 458 |
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... | 459 |
fn arity_is_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,
... | 460 |
async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
// axum logs rejections from built-in extractors with the `axum::rejection`
// target, at `TRACE` level. `axum::rejection=trace` enab... | 461 |
pub extern "x86-interrupt" fn floppy() { CommonInterruptHandler(38); } | 462 |
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
} | 463 |
fn main() {
if let Err(err) = Config::new().and_then(|conf| ui::user_menu(conf)) {
eprintln!("{}", err);
process::exit(1);
}
} | 464 |
fn modified_file() {
fn just_read(mut file: IoResult<File>) -> IoResult<Option<Vec<u8>>> {
file.read_to_end().map(|v| Some(v))
}
let file = CachedProcessedFile::new(Path::new("LICENSE"), None, just_read);
assert_eq!(file.expired(), true);
assert!(file.borrow().as_ref().map(|v| v.len()).unwr... | 465 |
fn inc_19() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(Direct(ECX)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 65], OperandSize::Word)
} | 466 |
pub fn write_f32<W>(wr: &mut W, val: f32) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::F32));
write_data_f32(wr, val)
} | 467 |
fn check_coordinates(x : i32, y : i32) -> bool {
return 0 <= x && x < 640 && 0 <= y && y < 480;
} | 468 |
pub fn causet_partitioner_request_new(prev_user_soliton_id: &[u8], current_user_soliton_id: &[u8], current_output_file_size: u64) -> Box<CausetPartitionerRequest> {
Box::new(CausetPartitionerRequest {
prev_user_soliton_id,
current_user_soliton_id,
current_output_file_size,
})
} | 469 |
fn copy_test() {
{
/*
struct Label {
number: u32,
}
fn print(l: Label) {
println!("STAMP: {}", l.number);
}
let l = Label { number: 3 };
print(l);
println!("My label number is: {}", l.number); // error
*/
#[der... | 470 |
fn debg(t: impl Debug) -> String {
format!("{:?}", t)
} | 471 |
fn fist_3() {
run_test(&Instruction { mnemonic: Mnemonic::FIST, operand1: Some(IndirectScaledDisplaced(RSI, Two, 1869896401, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[219, 20, 117... | 472 |
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() {
... | 473 |
pub fn spl_op(inputs: OpInputs) -> EmulatorResult<()> {
// SPL queues the next instruction (PC + 1) and then queues the sum of the
// program counter and A-pointer. If the queue is full, only the next
// instruction is queued.
let next_pc = offset(inputs.regs.current.idx, 1, inputs.core_size);
input... | 474 |
unsafe
fn
atomic_load
<
T
>
(
src
:
*
mut
T
)
-
>
T
where
T
:
Copy
{
atomic
!
{
T
a
{
a
=
&
*
(
src
as
*
const
_
as
*
const
_
)
;
mem
:
:
transmute_copy
(
&
a
.
load
(
Ordering
:
:
Acquire
)
)
}
{
let
lock
=
lock
(
src
as
usize
)
;
/
/
Try
doing
an
optimistic
read
first
.
if
let
Some
(
stamp
)
=
lock
.
optimistic_read
... | 475 |
fn get_platform() -> Platform {
match env::var("TARGET").unwrap().split('-').nth(2).unwrap() {
"win32" | "windows" => Platform::Windows,
"darwin" => Platform::Mac,
"linux" => Platform::Linux,
other => panic!("Sorry, platform \"{}\" is not supported by CEF.", other),
}
} | 476 |
fn start_tracking(interface: &NetworkInterface, just_me: bool) {
let mut pt = PacketTracker::new(interface.clone(), just_me);
// Create a new channel, dealing with layer 2 packets
let (_tx, mut rx) = match datalink::channel(&interface, Default::default()) {
Ok(Ethernet(tx, rx)) => (tx, rx),
... | 477 |
pub fn check_mmap_ptr(ptr: Ptr) -> io::Result<Ptr> {
if ptr == -1 as isize as *mut c_void {
let err = errno();
Err(io::Error::new(io::ErrorKind::Other, format!("mmap failed: [{}] {}", err.0, err)))
} else {
Ok(ptr)
}
} | 478 |
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... | 479 |
pub fn run() {
let result = is_permutation("abc", "cba");
println!("Result: {}", result);
} | 480 |
fn item_repo_over_named_user_query() {
let dir = TestDir::new("sit", "repo_over_named_user_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"});
... | 481 |
async fn next_page(host: &str, page: Option<i32>) -> BinaryEdgeResponse {
dotenv().ok();
let uri = build_url(host, page);
let api_key = env::var("BINARYEDGE_TOKEN")
.expect("BINARYEDGE_TOKEN must be set in order to use Binaryedge as a data source");
surf::get(uri)
.set_header("X-Key", a... | 482 |
fn a_table_should_preserve_the_money_supply() {
let mut table = HashMapOfTreeMap::new();
broker(&mut table, 1000);
expect_money_conserved(&table);
} | 483 |
fn assert_schema_is_the_same(
rule_name: &str,
prev_plan: &LogicalPlan,
new_plan: &LogicalPlan,
) -> Result<()> {
let equivalent = new_plan
.schema()
.equivalent_names_and_types(prev_plan.schema());
if !equivalent {
let e = DataFusionError::Internal(format!(
"Opt... | 484 |
pub fn print(buffer: [u8; 32], size: usize) {
let _ = system_call(SystemCall::Print {
request: (buffer, size)
});
} | 485 |
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
}));
... | 486 |
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);
}
} | 487 |
pub fn challenge_9() {
let data = "YELLOW SUBMARINE".as_bytes().to_vec();
let out = crypto::pkcs7_padding(&data, 20);
println!("{}", hex::encode(&out));
assert_eq!(out.len(), 20);
assert_eq!(hex::encode(&out), "59454c4c4f57205355424d4152494e4504040404");
} | 488 |
fn copy_icons(settings: &Settings) -> crate::Result<PathBuf> {
let base_dir = settings.project_out_directory();
let resource_dir = base_dir.join("resources");
let mut image_path = PathBuf::from(settings.project_out_directory());
// pop off till in tauri_src dir
image_path.pop();
image_path.pop();
// g... | 489 |
pub fn benchmark(c: &mut Criterion) {
const EXPRESSION: &str = include_str!("./expression.js");
c.bench_function("parse_expression", |b| {
b.iter_batched(
|| {
let source = Source::from_string(EXPRESSION.to_string());
let atoms = Atoms::new();
... | 490 |
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 ... | 491 |
pub extern "x86-interrupt" fn device_not_avalidable() { CommonExceptionHandler( 7); } | 492 |
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... | 493 |
async fn main() -> std::io::Result<()> {
// Set keep-alive to 75 seconds
let _one = HttpServer::new(app).keep_alive(Duration::from_secs(75));
// Use OS's keep-alive (usually quite long)
let _two = HttpServer::new(app).keep_alive(KeepAlive::Os);
// Disable keep-alive
let _three = HttpServer::ne... | 494 |
fn foreign_keys_are_preserved_when_generating_data_model_from_a_schema() {
let ref_data_model = Datamodel {
models: vec![
Model {
database_name: None,
name: "City".to_string(),
documentation: None,
is_embedded: false,
... | 495 |
fn inc_24() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(Indirect(RCX, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[255, 1], OperandSize::Qword)
} | 496 |
pub fn new_cube() -> Tess {
let vertices: &[([f32; 3], [f32; 3], [f32; 2])] = &[
// front face
([ 1., -1., 1.], [ 0., 0., 1.], [1., 0.]), // 0
([ 1., 1., 1.], [ 0., 0., 1.], [1., 1.]),
([-1., -1., 1.], [ 0., 0., 1.], [0., 0.]),
([-1., 1., 1.], [ 0., 0., 1.], [0., 1.]),
// back fa... | 497 |
pub fn write_i8<W>(wr: &mut W, val: i8) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::I8));
write_data_i8(wr, val)
} | 498 |
pub fn causet_partitioner_scan(
request: Box<CausetPartitionerRequest>,
result: Box<CausetPartitionerResult>,
) -> Box<CausetPartitionerResult> {
result
} | 499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.