file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
no_0501_find_mode_in_binary_search_tree.rs
use crate::common::TreeNode; use std::cell::RefCell; use std::rc::Rc; struct Answer { base: i32, count: u32, max_count: u32, v: Vec<i32>, } impl Answer { fn
() -> Self { Answer { base: 0, count: 0, max_count: 0, v: Vec::new(), } } fn update(&mut self, n: i32) { if self.base == n { self.count += 1; } else { self.base = n; self.count = 1; } ...
new
identifier_name
lib.rs
#![deny(missing_docs)] #![allow(dead_code)] //! The Essence language compiler //! //! Contains modules for each compiler phase //! //! # Phases //! //! Most of the phases are contained in their own modules. //! //! Tokenize -> Parse -> Analyze -> Macro Expand -> Type Check -> Optimize -> //! Codegen //! //! ## `tokeni...
mod error; mod context; /// Tokenizer phase. pub mod tokenizer; /// Parser phase. pub mod parser; mod analyzer; mod macro_expander; mod type_checker; mod code_gen; /// A compiler pub struct Compiler;
//! ## `code_gen` //! //! This module contains the default code generator implementation.
random_line_split
lib.rs
#![deny(missing_docs)] #![allow(dead_code)] //! The Essence language compiler //! //! Contains modules for each compiler phase //! //! # Phases //! //! Most of the phases are contained in their own modules. //! //! Tokenize -> Parse -> Analyze -> Macro Expand -> Type Check -> Optimize -> //! Codegen //! //! ## `tokeni...
;
Compiler
identifier_name
unique-swap.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut i: Box<_> = box 100; let mut j: Box<_> = box 200; swap(&mut i, &mut j); assert_eq!(i, box 200); assert_eq!(j, box 100); }
main
identifier_name
unique-swap.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut i: Box<_> = box 100; let mut j: Box<_> = box 200; swap(&mut i, &mut j); assert_eq!(i, box 200); assert_eq!(j, box 100); }
identifier_body
unique-swap.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let mut i: Box<_> = box 100; let mut j: Box<_> = box 200; swap(&mut i, &mut j); assert_eq!(i, box 200); assert_eq!(j, box 100); }
random_line_split
private-inferred-type-1.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) {} } impl ::TyParam for Option<Priv> { fn ty_param_secret(&self) {} } } fn main() { [].arr0_secret(); //~ ERROR type `m::Priv` is private None.ty_param_secret(); //~ ERROR type `m::Priv` is private }
arr0_secret
identifier_name
private-inferred-type-1.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
None.ty_param_secret(); //~ ERROR type `m::Priv` is private }
impl ::TyParam for Option<Priv> { fn ty_param_secret(&self) {} } } fn main() { [].arr0_secret(); //~ ERROR type `m::Priv` is private
random_line_split
da2013.rs
use std::os::unix::io; use byteorder::{LittleEndian, WriteBytesExt}; use nix; use nix::fcntl; use nix::sys::stat::Mode; use nix::unistd; mod hid_ioctl { const HID_IOC_MAGIC: u8 = b'H'; const HID_IOC_NR_SFEATURE: u8 = 0x06; const HID_IOC_NR_GFEATURE: u8 = 0x07; ioctl!(readwrite buf sfeature with HID_I...
} impl Drop for Da2013 { fn drop(&mut self) { unistd::close(self.fd).expect("Failed to close device"); } }
{ let (arg0, arg1, footer) = match (led, state) { (Led::Logo, true) => (0x0401, 1, 0x04), (Led::Logo, false) => (0x0401, 0, 0x05), (Led::Wheel, true) => (0x0101, 1, 0x01), (Led::Wheel, false) => (0x0101, 0, 0x00), }; self.do_cmd(DA2013_CMD_SET, DA...
identifier_body
da2013.rs
use std::os::unix::io; use byteorder::{LittleEndian, WriteBytesExt}; use nix; use nix::fcntl; use nix::sys::stat::Mode; use nix::unistd; mod hid_ioctl { const HID_IOC_MAGIC: u8 = b'H'; const HID_IOC_NR_SFEATURE: u8 = 0x06; const HID_IOC_NR_GFEATURE: u8 = 0x07; ioctl!(readwrite buf sfeature with HID_I...
buf.write_u16::<LittleEndian>(arg1).unwrap(); // Padding let mut zeros = vec![0; 76]; buf.append(&mut zeros); buf.push(footer); // Padding buf.push(0); // Errors here are considered non-critical // We try multiple times to make sure the device ...
random_line_split
da2013.rs
use std::os::unix::io; use byteorder::{LittleEndian, WriteBytesExt}; use nix; use nix::fcntl; use nix::sys::stat::Mode; use nix::unistd; mod hid_ioctl { const HID_IOC_MAGIC: u8 = b'H'; const HID_IOC_NR_SFEATURE: u8 = 0x06; const HID_IOC_NR_GFEATURE: u8 = 0x07; ioctl!(readwrite buf sfeature with HID_I...
(&mut self) { unistd::close(self.fd).expect("Failed to close device"); } }
drop
identifier_name
lib.rs
#![feature(plugin_registrar, quote, rustc_private, box_patterns)] extern crate rustc_plugin; #[macro_use] pub extern crate syntax; extern crate rustc_errors as errors; extern crate peg; use syntax::ast; use syntax::codemap; use syntax::codemap::FileName; use syntax::ext::base::{ExtCtxt, MacResult, MacEager, DummyResu...
reg.register_syntax_extension( Symbol::intern("peg_file"), syntax::ext::base::IdentTT(Box::new(expand_peg_file), None, false)); } fn expand_peg_str<'s>(cx: &'s mut ExtCtxt, sp: codemap::Span, ident: ast::Ident, tts: Vec<TokenTree>) -> Box<MacResult +'s> { let (source, span) = match par...
Symbol::intern("peg"), syntax::ext::base::IdentTT(Box::new(expand_peg_str), None, false));
random_line_split
lib.rs
#![feature(plugin_registrar, quote, rustc_private, box_patterns)] extern crate rustc_plugin; #[macro_use] pub extern crate syntax; extern crate rustc_errors as errors; extern crate peg; use syntax::ast; use syntax::codemap; use syntax::codemap::FileName; use syntax::ext::base::{ExtCtxt, MacResult, MacEager, DummyResu...
fn expand_peg_file<'s>(cx: &'s mut ExtCtxt, sp: codemap::Span, ident: ast::Ident, tts: Vec<TokenTree>) -> Box<MacResult +'s> { let fname = match parse_arg(cx, &tts) { Some((fname, _)) => fname, None => return DummyResult::any(sp), }; let path = match cx.codemap().span_to_filename(sp) { ...
{ let (source, span) = match parse_arg(cx, &tts) { Some((source, span)) => (source, span), None => return DummyResult::any(sp), }; let loc = cx.codemap().lookup_char_pos(span.lo()); let fname = loc.file.name.to_string(); // Make PEG line numbers match source line numbers let so...
identifier_body
lib.rs
#![feature(plugin_registrar, quote, rustc_private, box_patterns)] extern crate rustc_plugin; #[macro_use] pub extern crate syntax; extern crate rustc_errors as errors; extern crate peg; use syntax::ast; use syntax::codemap; use syntax::codemap::FileName; use syntax::ext::base::{ExtCtxt, MacResult, MacEager, DummyResu...
(cx: &mut ExtCtxt, tts: &[TokenTree]) -> Option<(String, codemap::Span)> { use syntax::print::pprust; let mut parser = parse::new_parser_from_tts(cx.parse_sess(), tts.to_vec()); // The `expand_expr` method is called so that any macro calls in the // parsed expression are expanded. let arg = cx.expa...
parse_arg
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![crate_name = "devtools_traits"] #![crate_type = "rlib"] #![comment = "The Servo Parallel Browser Project"] #![...
VoidValue, NullValue, BooleanValue(bool), NumberValue(f64), StringValue(String), ActorValue(String), } pub struct AttrInfo { pub namespace: String, pub name: String, pub value: String, } pub struct NodeInfo { pub uniqueId: String, pub baseURI: String, pub parent: String...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![crate_name = "devtools_traits"] #![crate_type = "rlib"] #![comment = "The Servo Parallel Browser Project"] #![...
{ VoidValue, NullValue, BooleanValue(bool), NumberValue(f64), StringValue(String), ActorValue(String), } pub struct AttrInfo { pub namespace: String, pub name: String, pub value: String, } pub struct NodeInfo { pub uniqueId: String, pub baseURI: String, pub parent: Str...
EvaluateJSReply
identifier_name
nfs2.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
nfs_status = stat; } SCLogDebug!("NFSv2: REPLY {} to procedure {} blob size {}", r.hdr.xid, xidmap.procedure, r.prog_data.len()); self.mark_response_tx_done(r.hdr.xid, r.reply_state, nfs_status, &resp_handle); } }
{ let mut nfs_status = 0; let resp_handle = Vec::new(); if xidmap.procedure == NFSPROC3_READ { match parse_nfs2_reply_read(r.prog_data) { Ok((_, ref reply)) => { SCLogDebug!("NFSv2: READ reply record"); self.process_read_record...
identifier_body
nfs2.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
<'b>(&mut self, r: &RpcPacket<'b>) { SCLogDebug!("NFSv2: REQUEST {} procedure {} ({}) blob size {}", r.hdr.xid, r.procedure, self.requestmap.len(), r.prog_data.len()); let mut xidmap = NFSRequestXidMap::new(r.progver, r.procedure, 0); let aux_file_name = Vec::new(); if ...
process_request_record_v2
identifier_name
nfs2.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
, }; } if!(r.procedure == NFSPROC3_COMMIT || // commit handled separately r.procedure == NFSPROC3_WRITE || // write handled in file tx r.procedure == NFSPROC3_READ) // read handled in file tx at reply { let mut tx = self.new_tx(); ...
{ self.set_event(NFSEvent::MalformedData); }
conditional_block
nfs2.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
use crate::nfs::types::*; use crate::nfs::rpc_records::*; use crate::nfs::nfs2_records::*; use nom::IResult; use nom::number::streaming::be_u32; impl NFSState { /// complete request record pub fn process_request_record_v2<'b>(&mut self, r: &RpcPacket<'b>) { SCLogDebug!("NFSv2: REQUEST {} procedure {} ...
use crate::log::*; use crate::nfs::nfs::*;
random_line_split
divisible_by_power_of_2.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2; impl<'a> DivisibleByPowerOf2 for &'a Integer { /// Returns whether `self` is divisible by 2<sup>`pow`</sup>. If `self` is 0, the result is /// always true; otherwise, it is equivalent to `self.trailing_zeros().unwrap() <= p...
}
{ self.abs.divisible_by_power_of_2(pow) }
identifier_body
divisible_by_power_of_2.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2; impl<'a> DivisibleByPowerOf2 for &'a Integer { /// Returns whether `self` is divisible by 2<sup>`pow`</sup>. If `self` is 0, the result is /// always true; otherwise, it is equivalent to `self.trailing_zeros().unwrap() <= p...
/// ``` /// extern crate malachite_base; /// extern crate malachite_nz; /// /// use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2; /// use malachite_base::num::basic::traits::Zero; /// use malachite_nz::integer::Integer; /// /// assert_eq!(Integer::ZERO.divisible_by_po...
/// /// where n = `self.significant_bits` /// /// # Examples
random_line_split
divisible_by_power_of_2.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2; impl<'a> DivisibleByPowerOf2 for &'a Integer { /// Returns whether `self` is divisible by 2<sup>`pow`</sup>. If `self` is 0, the result is /// always true; otherwise, it is equivalent to `self.trailing_zeros().unwrap() <= p...
(self, pow: u64) -> bool { self.abs.divisible_by_power_of_2(pow) } }
divisible_by_power_of_2
identifier_name
feature_representation.rs
// // This file is part of zero_sum. // // zero_sum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // zero_sum is distributed in...
// 1 - Black reserve flatstones features.push(state.p2_flatstones as f32 / 21.0); // 1 - Empty board spaces let mut stacks = state.board.iter().flat_map(|column| column.iter()).enumerate().map(|(i, stack)| (stack, (i / 5) as f32 / 4.0, (i % 5) as f32 / 4.0)).collect::<Vec<_>>(); features.push(stack...
// 1 - White reserve flatstones features.push(state.p1_flatstones as f32 / 21.0);
random_line_split
feature_representation.rs
// // This file is part of zero_sum. // // zero_sum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // zero_sum is distributed in...
for level in (0..len - 1).rev() { let carry = bitmap & accumulator[level]; accumulator[level] ^= carry; accumulator[level + 1] |= carry; bitmap ^= carry; } accumulator[0] |= bitmap; } let own_blocks = blocks & own_pieces; let mut s...
{ accumulator[len - 1] ^= carry; accumulator.push(carry); bitmap ^= carry; }
conditional_block
feature_representation.rs
// // This file is part of zero_sum. // // zero_sum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // zero_sum is distributed in...
(mut bitmap: Bitmap) -> (f32, f32) { if bitmap == 0 { return (0.0, 0.0); } let mut x = 0; while bitmap & EDGE[5][Direction::West as usize] == 0 { bitmap <<= 1; x += 1; } let mut y = 0; while bitmap & EDGE[5][Direction::South as usize] == 0 { bitmap >>= 5; ...
get_position
identifier_name
feature_representation.rs
// // This file is part of zero_sum. // // zero_sum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // zero_sum is distributed in...
accumulator[0] |= bitmap; } let own_blocks = blocks & own_pieces; let mut stack_levels = Vec::new(); add_bitmap(&mut stack_levels, own_blocks); for &level in own_stacks { add_bitmap(&mut stack_levels, level & own_pieces); } let add_influence = |influence: &mut Vec<Bitmap...
{ if accumulator.is_empty() { accumulator.push(bitmap); return; } let len = accumulator.len(); let carry = bitmap & accumulator[len - 1]; if carry != 0 { accumulator[len - 1] ^= carry; accumulator.push(carry); bitmap ^=...
identifier_body
mod.rs
pub mod handlers; pub mod middleware; pub mod requests; pub mod responses; pub mod tokens; use crate::api::requests::brand_requests::{EditBrandRequest, NewBrandRequest}; use actix_web::HttpRequest; use actix_web::{error, web, FromRequest, HttpResponse}; use handlers::catalog::brand_handlers; use handlers::{account_han...
.route(web::post().to(brand_handlers::post_new_brand)) ) .service( web::resource("/{brand}") .app_data(web::Json::<EditBrandRequest>::configure(|cfg| { cfg.error_handler(json_error_handler) ...
{ #[rustfmt::skip] cfg.service( web::scope("/api/v1") .service( web::resource("/authenticate") .route(web::post().to(account_handlers::authenticate)) ) .service( web::resource("/health_check") .ro...
identifier_body
mod.rs
pub mod handlers; pub mod middleware; pub mod requests; pub mod responses; pub mod tokens; use crate::api::requests::brand_requests::{EditBrandRequest, NewBrandRequest}; use actix_web::HttpRequest; use actix_web::{error, web, FromRequest, HttpResponse}; use handlers::catalog::brand_handlers; use handlers::{account_han...
})) .route(web::get().to(brand_handlers::get_brand)) .route(web::put().to(brand_handlers::edit_brand)) ) ) ); } fn json_error_handler(err: error::JsonPayloadError, _req: &HttpRequest) -> error::Error { use actix_w...
cfg.error_handler(json_error_handler)
random_line_split
mod.rs
pub mod handlers; pub mod middleware; pub mod requests; pub mod responses; pub mod tokens; use crate::api::requests::brand_requests::{EditBrandRequest, NewBrandRequest}; use actix_web::HttpRequest; use actix_web::{error, web, FromRequest, HttpResponse}; use handlers::catalog::brand_handlers; use handlers::{account_han...
(err: error::JsonPayloadError, _req: &HttpRequest) -> error::Error { use actix_web::error::JsonPayloadError; let detail = err.to_string(); let resp = match &err { JsonPayloadError::ContentType => HttpResponse::UnsupportedMediaType().body(detail), JsonPayloadError::Deserialize(json_err) if j...
json_error_handler
identifier_name
LoLS.rs
pub fn length_of_longest_substring(s: String) -> i32 { let mut temp_cache = vec![]; let mut to_bytes = s.bytes(); let mut result: i32 = 0; while let Some(b) = to_bytes.next() { if temp_cache.contains(&b) { if temp_cache.len() as i32 >= result { result = temp_cache.len...
() { dbg!(length_of_longest_substring(String::from("abcabcb"))); //=> 3 dbg!(length_of_longest_substring(String::from("bbb"))); //=> 1 dbg!(length_of_longest_substring(String::from("pwwkew"))); //=> 3 dbg!(length_of_longest_substring(String::from("dvdf"))); //=> 3 }
main
identifier_name
LoLS.rs
pub fn length_of_longest_substring(s: String) -> i32 { let mut temp_cache = vec![]; let mut to_bytes = s.bytes(); let mut result: i32 = 0; while let Some(b) = to_bytes.next() { if temp_cache.contains(&b) { if temp_cache.len() as i32 >= result { result = temp_cache.len...
fn main() { dbg!(length_of_longest_substring(String::from("abcabcb"))); //=> 3 dbg!(length_of_longest_substring(String::from("bbb"))); //=> 1 dbg!(length_of_longest_substring(String::from("pwwkew"))); //=> 3 dbg!(length_of_longest_substring(String::from("dvdf"))); //=> 3 }
} else { result } }
random_line_split
LoLS.rs
pub fn length_of_longest_substring(s: String) -> i32 { let mut temp_cache = vec![]; let mut to_bytes = s.bytes(); let mut result: i32 = 0; while let Some(b) = to_bytes.next() { if temp_cache.contains(&b) { if temp_cache.len() as i32 >= result { result = temp_cache.len...
} if temp_cache.len() as i32 > result { temp_cache.len() as i32 } else { result } } fn main() { dbg!(length_of_longest_substring(String::from("abcabcb"))); //=> 3 dbg!(length_of_longest_substring(String::from("bbb"))); //=> 1 dbg!(length_of_longest_substring(String::from("p...
{ temp_cache.push(b); }
conditional_block
LoLS.rs
pub fn length_of_longest_substring(s: String) -> i32
} } fn main() { dbg!(length_of_longest_substring(String::from("abcabcb"))); //=> 3 dbg!(length_of_longest_substring(String::from("bbb"))); //=> 1 dbg!(length_of_longest_substring(String::from("pwwkew"))); //=> 3 dbg!(length_of_longest_substring(String::from("dvdf"))); //=> 3 }
{ let mut temp_cache = vec![]; let mut to_bytes = s.bytes(); let mut result: i32 = 0; while let Some(b) = to_bytes.next() { if temp_cache.contains(&b) { if temp_cache.len() as i32 >= result { result = temp_cache.len() as i32 } let index = temp_...
identifier_body
message.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
fn get_root_internal(&self) -> Result<any_pointer::Reader> { unsafe { let segment : *const SegmentReader = &self.arena.segment0; let pointer_reader = try!(layout::PointerReader::get_root( segment, (*segment).get_start_ptr(), self.options.nesting_limit)); ...
{ let boxed_segments = Box::new(segments); let boxed_segments_ref = { let r :&S = &*boxed_segments; unsafe { ::std::mem::transmute(r as &ReaderSegments) } }; let arena = ReaderArena::new(boxed_segments_ref, options); Reader { arena: arena, segments: boxed_...
identifier_body
message.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
pub fn init_root<'a, T : FromPointerBuilder<'a>>(&'a mut self) -> T { self.get_root_internal().init_as() } /// Gets the root, interpreting it as the given type. pub fn get_root<'a, T : FromPointerBuilder<'a>>(&'a mut self) -> Result<T> { self.get_root_internal().get_as() } /// ...
} /// Initializes the root as a value of the given type.
random_line_split
message.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
else { self.allocator.allocate_segment(minimum_size) } } fn pre_drop(&mut self, segment0_currently_allocated: u32) { let ptr = self.scratch_space.slice.as_mut_ptr(); unsafe { ::std::ptr::write_bytes(ptr, 0u8, segment0_currently_allocated as usize); } ...
{ self.scratch_space.in_use = true; (self.scratch_space.slice.as_mut_ptr(), self.scratch_space.slice.len() as u32) }
conditional_block
message.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
(scratch_space: &'a mut ScratchSpace<'b>) -> ScratchSpaceHeapAllocator<'a, 'b> { ScratchSpaceHeapAllocator { scratch_space: scratch_space, allocator: HeapAllocator::new()} } pub fn second_segment_words(mut self, value: u32) -> ScratchSpaceHeapAllocator<'a, 'b> { ...
new
identifier_name
unreachable-code.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } pub fn main() {}
{}
conditional_block
unreachable-code.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() {}
} }
random_line_split
unreachable-code.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(x: bool) -> bool { x } fn call_id() { let c = panic!(); id(c); } fn call_id_2() { id(true) && id(return); } fn call_id_3() { id(return) && id(return); } fn ret_guard() { match 2 { x if (return) => { x; } _ => {} } } pub fn main() {}
id
identifier_name
unreachable-code.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn ret_guard() { match 2 { x if (return) => { x; } _ => {} } } pub fn main() {}
{ id(return) && id(return); }
identifier_body
test_linux_ip_addr.rs
extern crate linux_ip; // use std::io::prelude::*; #[cfg(test)] mod tests { use std::fs::File; use std::io::Read; use std::path::Path; fn ip_addr_show() -> String
#[test] fn test_me() { let ip_addr = ::linux_ip::addr::parse_from_string(&ip_addr_show()); assert_eq!(26, ip_addr.length()); assert_eq!("br995", ip_addr.find("br995").unwrap().name); assert_eq!(vec!["10.10.95.11/22", "10.10.95.12/22", "fe80::d227:88ff:fed1:16d/64"], ...
{ let mut f = File::open(Path::new("tests/ip_addr.out")).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).ok(); return s; }
identifier_body
test_linux_ip_addr.rs
extern crate linux_ip; // use std::io::prelude::*; #[cfg(test)] mod tests { use std::fs::File; use std::io::Read; use std::path::Path; fn ip_addr_show() -> String { let mut f = File::open(Path::new("tests/ip_addr.out")).unwrap(); let mut s = String::new(); f.read_to_string(&m...
() { let mut ip_addr = ::linux_ip::addr::IpAddr { interfaces: Vec::new() }; let idx = ip_addr.add_interface(&"eth0".to_string()); ip_addr.interfaces[idx].add_ip("47.11.1.1/26".to_string()); assert!(ip_addr.as_commands("del") .iter() .find(|s| *s == "ip addr del 47.1...
test_from_scratch
identifier_name
test_linux_ip_addr.rs
extern crate linux_ip; // use std::io::prelude::*; #[cfg(test)] mod tests { use std::fs::File; use std::io::Read; use std::path::Path; fn ip_addr_show() -> String { let mut f = File::open(Path::new("tests/ip_addr.out")).unwrap(); let mut s = String::new(); f.read_to_string(&mu...
assert!(ip_addr.as_commands("del") .iter() .find(|s| *s == "ip addr del 10.1.0.11/16 dev br110") .is_some()); } #[test] fn test_from_scratch() { let mut ip_addr = ::linux_ip::addr::IpAddr { interfaces: Vec::new() }; let idx = ip_addr.add_interface(&"e...
assert!(ip_addr.as_commands("add") .iter() .find(|s| *s == "ip addr add fe80::d227:88ff:fed1:16d/64 dev p1p1.402") .is_some());
random_line_split
error_types.rs
use std::error; use std::fmt; use std::io; pub struct GnuplotInitError { inner: Box<dyn error::Error +'static>, } impl From<io::Error> for GnuplotInitError { fn from(error: io::Error) -> Self { GnuplotInitError { inner: Box::new(error), } } } impl fmt::Display for GnuplotInitError { fn
(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "Couldn't spawn gnuplot. Make sure it is installed and available in PATH.\nCause: {}", self.inner ) } } impl fmt::Debug for GnuplotInitError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self) } } impl error::Er...
fmt
identifier_name
error_types.rs
use std::error; use std::fmt; use std::io; pub struct GnuplotInitError { inner: Box<dyn error::Error +'static>, } impl From<io::Error> for GnuplotInitError { fn from(error: io::Error) -> Self
} impl fmt::Display for GnuplotInitError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "Couldn't spawn gnuplot. Make sure it is installed and available in PATH.\nCause: {}", self.inner ) } } impl fmt::Debug for GnuplotInitError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Re...
{ GnuplotInitError { inner: Box::new(error), } }
identifier_body
error_types.rs
use std::error; use std::fmt; use std::io; pub struct GnuplotInitError { inner: Box<dyn error::Error +'static>, } impl From<io::Error> for GnuplotInitError { fn from(error: io::Error) -> Self { GnuplotInitError {
} impl fmt::Display for GnuplotInitError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "Couldn't spawn gnuplot. Make sure it is installed and available in PATH.\nCause: {}", self.inner ) } } impl fmt::Debug for GnuplotInitError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Res...
inner: Box::new(error), } }
random_line_split
explicit-self-lifetime-mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a,'b> { x: &'a int, y: &'b int, } impl<'a,'b> Foo<'a,'b> { // The number of errors is related to the way invariance works. fn bar(self: Foo<'b,'a>) {} //~^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'b,'a>` //~^^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'...
Foo
identifier_name
explicit-self-lifetime-mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{}
identifier_body
explicit-self-lifetime-mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// The number of errors is related to the way invariance works. fn bar(self: Foo<'b,'a>) {} //~^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'b,'a>` //~^^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'b,'a>` //~^^^ ERROR mismatched types: expected `Foo<'b,'a>` but fo...
random_line_split
vldmxcsr.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vldmxcsr_1() { run_test(&Instruction { mnemonic: Mnemonic::VLDMXCSR, operand1: Some(IndirectScaledIndexedDisplaced(ESI,...
{ run_test(&Instruction { mnemonic: Mnemonic::VLDMXCSR, operand1: Some(IndirectDisplaced(RAX, 2124348144, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 248, 174, 144, 240, 250, 1...
identifier_body
vldmxcsr.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*;
run_test(&Instruction { mnemonic: Mnemonic::VLDMXCSR, operand1: Some(IndirectDisplaced(RAX, 2124348144, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 248, 174, 144, 240, 250, 158...
fn vldmxcsr_1() { run_test(&Instruction { mnemonic: Mnemonic::VLDMXCSR, operand1: Some(IndirectScaledIndexedDisplaced(ESI, EDX, Two, 683715666, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: Non...
random_line_split
vldmxcsr.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::VLDMXCSR, operand1: Some(IndirectScaledIndexedDisplaced(ESI, EDX, Two, 683715666, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 2...
vldmxcsr_1
identifier_name
basic.rs
extern crate lichen; use lichen::parse::Parser; use lichen::var::Var; use lichen::eval::Evaluator; fn main()
// which either advances or continues on during the next step // see the contrived example to see this } }
{ //load the lichen source file as a string let bytes = include_bytes!("basic.ls"); let mut src = String::from_utf8_lossy(bytes); let mut env = Parser::parse_blocks(src.to_mut()).expect("ERROR: Unable to parse source").into_env(); //parse the source and build the environment let mut ev = Evalu...
identifier_body
basic.rs
extern crate lichen; use lichen::parse::Parser; use lichen::var::Var; use lichen::eval::Evaluator; fn
() { //load the lichen source file as a string let bytes = include_bytes!("basic.ls"); let mut src = String::from_utf8_lossy(bytes); let mut env = Parser::parse_blocks(src.to_mut()).expect("ERROR: Unable to parse source").into_env(); //parse the source and build the environment let mut ev = Ev...
main
identifier_name
basic.rs
extern crate lichen; use lichen::parse::Parser; use lichen::var::Var; use lichen::eval::Evaluator; fn main() { //load the lichen source file as a string let bytes = include_bytes!("basic.ls"); let mut src = String::from_utf8_lossy(bytes); let mut env = Parser::parse_blocks(src.to_mut()).expect("...
, // print out the emitted variables _ => {}, } } // if we wanted to we could look at the next_node returned, // and advance it manually if needed // you'd do this if the node were an await-style node, // which either advances or continues on during t...
{ println!("{:}", s); }
conditional_block
basic.rs
extern crate lichen; use lichen::parse::Parser; use lichen::var::Var; use lichen::eval::Evaluator; fn main() { //load the lichen source file as a string let bytes = include_bytes!("basic.ls"); let mut src = String::from_utf8_lossy(bytes); let mut env = Parser::parse_blocks(src.to_mut()).expect("...
// and advance it manually if needed // you'd do this if the node were an await-style node, // which either advances or continues on during the next step // see the contrived example to see this } }
// if we wanted to we could look at the next_node returned,
random_line_split
error.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including wi...
display("invalid palette: {}", reason) } } }
} errors { InvalidPalette(reason: &'static str) { description("invalid palette")
random_line_split
html.rs
//These tests were "borrowed" from html5ever. Some of them are not applicable, //since the purpose of Symbiosis is to recreate the original document as //closely as possible. extern crate symbiosis_tokenizer; use std::collections::HashMap; use symbiosis_tokenizer::{Tokenizer, TokenSink, StrTendril}; use symbiosis_to...
(&mut self, token: Token) { match token { Token::SetDoctype(doctype) => { self.buffer.push_str("<!DOCTYPE"); if let Some(ref name) = doctype.name { self.buffer.push_str(name); } if let Some(ref public_id) = doctype....
process_token
identifier_name
html.rs
//These tests were "borrowed" from html5ever. Some of them are not applicable, //since the purpose of Symbiosis is to recreate the original document as //closely as possible. extern crate symbiosis_tokenizer; use std::collections::HashMap; use symbiosis_tokenizer::{Tokenizer, TokenSink, StrTendril}; use symbiosis_to...
test!(comment_3, r#"<p>hi <!--world --></p>"#); test!(comment_4, r#"<p>hi <!-- world --></p>"#); test!(attr_ns_1, r#"<svg xmlns="bleh"></svg>"#); test!(attr_ns_2, r#"<svg xmlns:foo="bleh"></svg>"#); test!(attr_ns_3, r#"<svg xmlns:xlink="bleh"></svg>"#); test!(attr_ns_4, r#"<svg xlink:href="bleh"></svg>"#);
random_line_split
html.rs
//These tests were "borrowed" from html5ever. Some of them are not applicable, //since the purpose of Symbiosis is to recreate the original document as //closely as possible. extern crate symbiosis_tokenizer; use std::collections::HashMap; use symbiosis_tokenizer::{Tokenizer, TokenSink, StrTendril}; use symbiosis_to...
else if doctype.system_id.is_some() { self.buffer.push_str(" SYSTEM"); } if let Some(ref system_id) = doctype.system_id { self.buffer.push_str(&format!(" \"{}\"", system_id)); } self.buffer.push_str(">"); ...
{ self.buffer.push_str(&format!(" PUBLIC \"{}\"", public_id)); }
conditional_block
base32.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // #![crate_name = "uu_base32"] #[macro_use] extern crate uucore; use uucore::encodi...
static SYNTAX: &'static str = "[OPTION]... [FILE]"; static SUMMARY: &'static str = "Base32 encode or decode FILE, or standard input, to standard output."; static LONG_HELP: &'static str = " With no FILE, or when FILE is -, read standard input. The data are encoded as described for the base32 alphabet in RFC 4648....
random_line_split
base32.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // #![crate_name = "uu_base32"] #[macro_use] extern crate uucore; use uucore::encodi...
(args: Vec<String>) -> i32 { let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) .optflag("d", "decode", "decode data") .optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters") .optopt("w", "wrap", "...
uumain
identifier_name
base32.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // #![crate_name = "uu_base32"] #[macro_use] extern crate uucore; use uucore::encodi...
} None => 76, }; if matches.free.len() > 1 { disp_err!("extra operand ‘{}’", matches.free[0]); return 1; } let input = if matches.free.is_empty() || &matches.free[0][..] == "-" { BufReader::new(Box::new(stdin()) as Box<Read>) } else { let path = Path...
{ let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) .optflag("d", "decode", "decode data") .optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters") .optopt("w", "wrap", "wrap encoded lines after...
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(fnbox)] #![feature(mpsc_select)] #![feature(plugin)] #![feature(plugin)] #![plu...
extern crate tinyfiledialogs; extern crate unicase; extern crate url; extern crate util; extern crate uuid; extern crate webrender_traits; extern crate websocket; pub mod about_loader; pub mod chrome_loader; pub mod cookie; pub mod cookie_storage; pub mod data_loader; pub mod file_loader; pub mod hsts; pub mod http_lo...
extern crate rustc_serialize; extern crate threadpool; extern crate time; #[cfg(any(target_os = "macos", target_os = "linux"))]
random_line_split
archive_cache.rs
use { crate::{ cache::{ArchivedStructured, CacheRead, CacheWrite, OwnedRef, Structured}, deser::Deser, storage::{Error, StorageRead, StorageWrite}, Addr, }, log::warn, rkyv::{ archived_value, de::deserializers::AllocDeserializer, ser::{serializers:...
} // we could have a concurrency issue here, where we read from storage twice. // This is low-risk (ie won't corrupt data/etc), and should be tweaked based on // what results in better performance. // Optimizing for duplicate cache inserts vs holding the lock longer. // ...
{ return Ok(Arc::clone(&buf)); }
conditional_block
archive_cache.rs
use { crate::{ cache::{ArchivedStructured, CacheRead, CacheWrite, OwnedRef, Structured}, deser::Deser, storage::{Error, StorageRead, StorageWrite}, Addr, }, log::warn, rkyv::{ archived_value, de::deserializers::AllocDeserializer, ser::{serializers:...
<T>(&self, structured: T) -> Result<Addr, Error> where T: Into<Structured> + Send, { let structured = structured.into(); let addr = { let deser_buf = Deser::default().to_vec(&structured).unwrap(); Addr::hash(&deser_buf) }; let mut serializer = Writ...
write_structured
identifier_name
archive_cache.rs
use { crate::{ cache::{ArchivedStructured, CacheRead, CacheWrite, OwnedRef, Structured}, deser::Deser, storage::{Error, StorageRead, StorageWrite}, Addr, }, log::warn, rkyv::{ archived_value, de::deserializers::AllocDeserializer, ser::{serializers:...
fn into_owned(self) -> Structured { let archived = self.as_ref(); let mut deserializer = AllocDeserializer; let deserialized = archived.deserialize(&mut deserializer).unwrap(); deserialized } } #[async_trait::async_trait] impl<S> CacheWrite for ArchiveCache<S> where S: Stora...
{ unsafe { archived_value::<Structured>( self.0.as_slice(), // we're only serializing to the beginning of the buf. 0, ) } }
identifier_body
archive_cache.rs
use { crate::{ cache::{ArchivedStructured, CacheRead, CacheWrite, OwnedRef, Structured}, deser::Deser, storage::{Error, StorageRead, StorageWrite}, Addr, }, log::warn, rkyv::{ archived_value, de::deserializers::AllocDeserializer, ser::{serializers:...
let addr = Addr::hash(&buf); self.write_buf(&addr, buf).await?; Ok(addr) } async fn write_structured<T>(&self, structured: T) -> Result<Addr, Error> where T: Into<Structured> + Send, { let structured = structured.into(); let addr = { let deser_...
random_line_split
task-perf-alloc-unwind.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
res: r(box List::Cons((), st.res._l.clone())), } } }; recurse_or_panic(depth, Some(st)); } }
{ if depth == 0 { panic!(); } else { let depth = depth - 1; let st = match st { None => { State { unique: box List::Nil, vec: vec!(box List::Nil), res: r(box List::Nil) } ...
identifier_body
task-perf-alloc-unwind.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ unique: Box<nillist>, vec: Vec<Box<nillist>>, res: r } struct r { _l: Box<nillist>, } #[unsafe_destructor] impl Drop for r { fn drop(&mut self) {} } fn r(l: Box<nillist>) -> r { r { _l: l } } fn recurse_or_panic(depth: int, st: Option<State>) { if depth == 0 { panic!...
State
identifier_name
task-perf-alloc-unwind.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}); println!("iter: {}", dur); } } type nillist = List<()>; // Filled with things that have to be unwound struct State { unique: Box<nillist>, vec: Vec<Box<nillist>>, res: r } struct r { _l: Box<nillist>, } #[unsafe_destructor] impl Drop for r { fn drop(&mut self) {} } fn r(l...
for _ in 0..repeat { let dur = Duration::span(|| { let _ = Thread::scoped(move|| { recurse_or_panic(depth, None) }).join();
random_line_split
task-perf-alloc-unwind.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
else { let depth = depth - 1; let st = match st { None => { State { unique: box List::Nil, vec: vec!(box List::Nil), res: r(box List::Nil) } } Some(st) => { l...
{ panic!(); }
conditional_block
defaults.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
extern "C" { fn glGetIntegerv(pname: GLenum, params: *const GLint); } }
{ glGetIntegerv(pname, params) }
identifier_body
defaults.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
let (mut window, _) = glfw.create_window(640, 480, "Defaults", glfw::WindowMode::Windowed) .expect("Failed to create GLFW window."); window.make_current(); let (width, height) = window.get_size(); println!("window size: ({:?}, {:?})", width, height); println!("Context version: {:?}", ...
random_line_split
defaults.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
; } } mod gl { extern crate libc; #[cfg(target_os = "macos")] #[link(name="OpenGL", kind="framework")] extern { } #[cfg(target_os = "linux")] #[link(name="GL")] extern { } pub type GLenum = libc::c_uint; pub type GLint = libc::c_int; pub static RED_BITS : G...
{ let value = 0; unsafe { gl::GetIntegerv(param, &value) }; println!("OpenGL {:?}: {:?}", name, value); }
conditional_block
defaults.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
(pname: GLenum, params: *const GLint) { glGetIntegerv(pname, params) } extern "C" { fn glGetIntegerv(pname: GLenum, params: *const GLint); } }
GetIntegerv
identifier_name
task.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// TLS, or possibly some destructors for those objects being // annihilated invoke TLS. Sadly these two operations seemed to // be intertwined, and miraculously work for now... let mut task = Local::borrow(None::<Task>); let storage_map = {...
// that the destructors for the objects in TLS themselves invoke
random_line_split
task.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} impl BlockedTask { /// Returns Some if the task was successfully woken; None if already killed. pub fn wake(self) -> Option<Box<Task>> { match self { Owned(task) => Some(task), Shared(arc) => unsafe { match (*arc.get()).swap(0, SeqCst) { 0 ...
{ Some(Shared(self.inner.clone())) }
identifier_body
task.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(mut ~self) { let ops = self.imp.take_unwrap(); ops.reawaken(self); } /// Yields control of this task to another task. This function will /// eventually return, but possibly not immediately. This is used as an /// opportunity to allow other tasks a chance to run. pub fn yield_now(mu...
reawaken
identifier_name
character.rs
//! Operations on characters. use remacs_macros::lisp_fn; use remacs_sys::EmacsInt; use lisp::LispObject; use lisp::defsubr; use multibyte::{make_char_multibyte, raw_byte_from_codepoint_safe}; use multibyte::MAX_CHAR; /// Return the character of the maximum code. #[lisp_fn] pub fn max_char() -> LispObject { Lisp...
include!(concat!(env!("OUT_DIR"), "/character_exports.rs"));
{ let c = ch.as_character_or_error(); if c < 256 { // Can't distinguish a byte read from a unibyte buffer from // a latin1 char, so let's let it slide. ch } else { LispObject::from_fixnum(raw_byte_from_codepoint_safe(c)) } }
identifier_body
character.rs
//! Operations on characters. use remacs_macros::lisp_fn; use remacs_sys::EmacsInt; use lisp::LispObject; use lisp::defsubr; use multibyte::{make_char_multibyte, raw_byte_from_codepoint_safe}; use multibyte::MAX_CHAR; /// Return the character of the maximum code. #[lisp_fn] pub fn max_char() -> LispObject { Lisp...
(ch: LispObject) -> LispObject { let c = ch.as_character_or_error(); if c >= 0x100 { error!("Not a unibyte character: {}", c); } LispObject::from_fixnum(make_char_multibyte(c) as EmacsInt) } /// Convert the multibyte character CH to a byte. /// If the multibyte character does not represent a by...
unibyte_char_to_multibyte
identifier_name
character.rs
//! Operations on characters. use remacs_macros::lisp_fn; use remacs_sys::EmacsInt; use lisp::LispObject; use lisp::defsubr; use multibyte::{make_char_multibyte, raw_byte_from_codepoint_safe}; use multibyte::MAX_CHAR; /// Return the character of the maximum code. #[lisp_fn] pub fn max_char() -> LispObject { Lisp...
} include!(concat!(env!("OUT_DIR"), "/character_exports.rs"));
{ LispObject::from_fixnum(raw_byte_from_codepoint_safe(c)) }
conditional_block
character.rs
//! Operations on characters. use remacs_macros::lisp_fn; use remacs_sys::EmacsInt; use lisp::LispObject; use lisp::defsubr; use multibyte::{make_char_multibyte, raw_byte_from_codepoint_safe}; use multibyte::MAX_CHAR;
} /// Return non-nil if OBJECT is a character. /// In Emacs Lisp, characters are represented by character codes, which /// are non-negative integers. The function `max-char' returns the /// maximum character code. /// usage: (fn OBJECT) #[lisp_fn(min = "1")] pub fn characterp(object: LispObject, _ignore: LispObject) ...
/// Return the character of the maximum code. #[lisp_fn] pub fn max_char() -> LispObject { LispObject::from_fixnum(MAX_CHAR as EmacsInt)
random_line_split
domexception.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding; use crate::dom::bindings::codegen::Bindings::DO...
(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> { reflect_dom_object( Box::new(DOMException::new_inherited(code)), global, DOMExceptionBinding::Wrap, ) } } impl DOMExceptionMethods for DOMException { // https://heycam.github.io/webidl/#dfn...
new
identifier_name
domexception.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding; use crate::dom::bindings::codegen::Bindings::DO...
DOMErrorName::NamespaceError => "The operation is not allowed by Namespaces in XML.", DOMErrorName::InvalidAccessError => { "The object does not support the operation or argument." }, DOMErrorName::SecurityError => "The operation is insecure.", ...
DOMErrorName::SyntaxError => "The string did not match the expected pattern.", DOMErrorName::InvalidModificationError => "The object can not be modified in this way.",
random_line_split
lib.rs
extern crate byteorder; extern crate bytes; extern crate tokio_io; use std::io; use tokio_io::codec::{Encoder, Decoder}; use bytes::BytesMut; mod error; mod qos; mod conn_return_code; mod header; mod packet_type; pub struct Mqtt{} impl Mqtt{ pub fn
() -> Mqtt{ Mqtt{} } } impl Decoder for Mqtt{ type Item = String; type Error = io::Error; fn decode(&mut self, buf: &mut BytesMut) -> io::Result<Option<String>> { Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) } } impl Encoder...
new
identifier_name
lib.rs
extern crate byteorder; extern crate bytes; extern crate tokio_io; use std::io; use tokio_io::codec::{Encoder, Decoder}; use bytes::BytesMut; mod error; mod qos; mod conn_return_code; mod header; mod packet_type; pub struct Mqtt{} impl Mqtt{ pub fn new() -> Mqtt{ Mqtt{} } }
type Item = String; type Error = io::Error; fn decode(&mut self, buf: &mut BytesMut) -> io::Result<Option<String>> { Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) } } impl Encoder for Mqtt { type Item = String; type Error = io::Error;...
impl Decoder for Mqtt{
random_line_split
lib.rs
extern crate byteorder; extern crate bytes; extern crate tokio_io; use std::io; use tokio_io::codec::{Encoder, Decoder}; use bytes::BytesMut; mod error; mod qos; mod conn_return_code; mod header; mod packet_type; pub struct Mqtt{} impl Mqtt{ pub fn new() -> Mqtt{ Mqtt{} } } impl Decoder for...
} impl Encoder for Mqtt { type Item = String; type Error = io::Error; fn encode(&mut self, msg: String, buf: &mut BytesMut) -> io::Result<()> { Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) } }
{ Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) }
identifier_body
no_0337_house_robber_iii.rs
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
al: 2, left: node(TreeNode::new(3)), right: None, }), right: None, }), right: None, }); assert_eq!(Solution::rob(root), 7); // 选了开头的4和末尾的3. } fn node(n: TreeNode) -> Option<Rc<RefCell<TreeNode>>> { ...
identifier_body
no_0337_house_robber_iii.rs
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
val: 2, left: node(TreeNode::new(3)), right: None, }), right: None, }), right: None, }); assert_eq!(Solution::rob(root), 7); // 选了开头的4和末尾的3. } fn node(n: TreeNode) -> Option<Rc<RefCell<TreeNode>>> ...
identifier_name
no_0337_house_robber_iii.rs
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
} }
Some(Rc::new(RefCell::new(n)))
random_line_split
no_0337_house_robber_iii.rs
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
let left_res = Self::rob_helper(r.left.clone()); let right_res = Self::rob_helper(r.right.clone()); ( // 没有选中间节点,左右子节点可以选(这里错了) // left_res.1 + right_res.1, // 没有选中间节点时,左右子节点可以选,也可以不选 left_res.0.max(left_res.1) + right_res.0.max(right_res.1), ...
r = root.as_ref().unwrap().borrow();
conditional_block
shl.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u16x8; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u16x8(pub u16, pub u16, pub u16, pub u16, // pub u16, pub u16, pub u16, pub u16); #[test] fn
() { let x: u16x8 = u16x8( 0, 1, 2, 3, 4, 5, 6, 7 ); let y: u16x8 = u16x8( 2, 2, 2, 2, 2, 2, 2, 2 ); let z: u16x8 = x << y; let result: String = format!("{:?}", z); assert_eq!(result, "u16x8(\ 0, 4, 8, 12, 16, 20, 24, 28\ )".to_string()); } }
shl_test1
identifier_name
shl.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u16x8; // #[simd]
#[test] fn shl_test1() { let x: u16x8 = u16x8( 0, 1, 2, 3, 4, 5, 6, 7 ); let y: u16x8 = u16x8( 2, 2, 2, 2, 2, 2, 2, 2 ); let z: u16x8 = x << y; let result: String = format!("{:?}", z); assert_eq!(result, "u16x8(\ 0, 4, 8, 12, 16, 20, 24, 28\ )".to_string()); } }
// #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u16x8(pub u16, pub u16, pub u16, pub u16, // pub u16, pub u16, pub u16, pub u16);
random_line_split
shl.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u16x8; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u16x8(pub u16, pub u16, pub u16, pub u16, // pub u16, pub u16, pub u16, pub u16); #[test] fn shl_tes...
}
{ let x: u16x8 = u16x8( 0, 1, 2, 3, 4, 5, 6, 7 ); let y: u16x8 = u16x8( 2, 2, 2, 2, 2, 2, 2, 2 ); let z: u16x8 = x << y; let result: String = format!("{:?}", z); assert_eq!(result, "u16x8(\ 0, 4, 8, 12, 16, 20, 24, 28\ )".to_string()); }
identifier_body
inprocess.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::gl_context::GLContextFactory; use crate::webgl_thread::{WebGLMainThread, WebGLThread, WebGLThreadInit};...
(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self { OutputHandler { webrender_gl, webgl_channel: channel, lock_channel: webgl_channel().unwrap(), sync_objects: Default::default(), } } } /// Bridge between the WR frame outputs and ...
new
identifier_name
inprocess.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::gl_context::GLContextFactory; use crate::webgl_thread::{WebGLMainThread, WebGLThread, WebGLThreadInit};...
} } /// struct used to implement DOMToTexture feature and webrender::OutputImageHandler trait. type OutputHandlerData = Option<(u32, Size2D<i32>)>; struct OutputHandler { webrender_gl: Rc<dyn gl::Gl>, webgl_channel: WebGLSender<WebGLMsg>, // Used to avoid creating a new channel on each received WebRend...
self.sendable.unlock(id as usize);
random_line_split
inprocess.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::gl_context::GLContextFactory; use crate::webgl_thread::{WebGLMainThread, WebGLThread, WebGLThreadInit};...
(image_id, size, Some(gl_sync as gl::GLsync)) } } } impl webxr_api::WebGLExternalImageApi for SendableWebGLExternalImages { fn lock(&self, id: usize) -> Option<gl::GLsync> { let (_, _, gl_sync) = self.lock_and_get_current_texture(id); gl_sync } fn unlock(&self, id:...
{ if let Some(main_thread) = WebGLMainThread::on_current_thread() { // If we're on the same thread as WebGL, we can get the data directly let (image_id, size) = main_thread .thread_data .borrow_mut() .handle_lock_unsync(WebGLContextId(id as...
identifier_body