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 |
|---|---|---|---|---|
lib.rs | #![allow(unused_variables, unused_imports, dead_code)]
use m3u8_rs::*;
use nom::AsBytes;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::path;
fn all_sample_m3u_playlists() -> Vec<path::PathBuf> {
let path: std::path::PathBuf = ["sample-playlists"].iter().collect();
... | (path: &str) -> String {
let mut buf = String::new();
let mut file = fs::File::open(path).unwrap_or_else(|_| panic!("Can't find m3u8: {}", path));
let u = file.read_to_string(&mut buf).expect("Can't read file");
buf
}
fn get_sample_playlist(name: &str) -> String {
let path: std::path::PathBuf = ["s... | getm3u | identifier_name |
lib.rs | #![allow(unused_variables, unused_imports, dead_code)]
use m3u8_rs::*;
use nom::AsBytes;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::path;
fn all_sample_m3u_playlists() -> Vec<path::PathBuf> {
let path: std::path::PathBuf = ["sample-playlists"].iter().collect();
... |
#[test]
fn playlist_media_with_cues() {
assert!(print_parse_playlist_test("media-playlist-with-cues.m3u8"));
}
#[test]
fn playlist_media_with_cues1() {
assert!(print_parse_playlist_test("media-playlist-with-cues-1.m3u8"));
}
#[test]
fn playlist_media_with_scte35() {
assert!(print_parse_playlist_test("me... | {
assert!(print_parse_playlist_test(
"media-playlist-without-segments.m3u8"
));
} | identifier_body |
lib.rs | #![allow(unused_variables, unused_imports, dead_code)]
use m3u8_rs::*;
use nom::AsBytes;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::path;
fn all_sample_m3u_playlists() -> Vec<path::PathBuf> {
let path: std::path::PathBuf = ["sample-playlists"].iter().collect();
... | keyformatversions: Some("xXFormatVers".into()),
})],
start: Some(Start {
time_offset: "123123123".into(),
precise: Some("YES".into()),
}),
independent_segments: true,
unknown_tags: vec![],
});
let playlist_parsed = print_create_and_pars... | session_key: vec![SessionKey(Key {
method: "AES-128".into(),
uri: Some("https://secure.domain.com".into()),
iv: Some("0xb059217aa2649ce170b734".into()),
keyformat: Some("xXkeyformatXx".into()), | random_line_split |
csskeyframesrule.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/. */
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::... |
}
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-findrule
fn FindRule(&self, selector: DOMString) -> Option<Root<CSSKeyframeRule>> {
self.find_rule(&selector).and_then(|idx| {
self.rulelist().item(idx as u32)
}).and_then(Root::downcast)
}
// https://d... | {
let _ = self.rulelist().remove_rule(idx as u32);
} | conditional_block |
csskeyframesrule.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/. */
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::... | (&self, selector: &str) -> Option<usize> {
let mut input = Parser::new(selector);
if let Ok(sel) = KeyframeSelector::parse(&mut input) {
// This finds the *last* element matching a selector
// because that's the rule that applies. Thus, rposition
self.keyframesrule.re... | find_rule | identifier_name |
csskeyframesrule.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/. */
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::... | #[ignore_heap_size_of = "Arc"]
keyframesrule: Arc<RwLock<KeyframesRule>>,
rulelist: MutNullableJS<CSSRuleList>,
}
impl CSSKeyframesRule {
fn new_inherited(parent_stylesheet: &CSSStyleSheet, keyframesrule: Arc<RwLock<KeyframesRule>>)
-> CSSKeyframesRule {
CSSKeyframesRule {
... | random_line_split | |
csskeyframesrule.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/. */
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::... |
#[allow(unrooted_must_root)]
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
keyframesrule: Arc<RwLock<KeyframesRule>>) -> Root<CSSKeyframesRule> {
reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule),
window,... | {
CSSKeyframesRule {
cssrule: CSSRule::new_inherited(parent_stylesheet),
keyframesrule: keyframesrule,
rulelist: MutNullableJS::new(None),
}
} | identifier_body |
recorder.rs | // The MIT License (MIT)
//
// Copyright (c) 2013 Jeremy Letang (letang.jeremy@gmail.com)
//
// 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 without limitati... |
pub fn start(&mut self) {
let (stop_sender, stop_receiver) = channel();
let (data_sender, data_receiver) = channel();
let r_c = self.ctxt.clone();
self.stop_sender = Some(stop_sender);
self.data_receiver = Some(data_receiver);
task::spawn(proc() {
let ... | {
Recorder {
ctxt: record_context,
stop_sender: None,
data_receiver: None,
samples: Vec::new()
}
} | identifier_body |
recorder.rs | // The MIT License (MIT)
//
// Copyright (c) 2013 Jeremy Letang (letang.jeremy@gmail.com)
//
// 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 without limitati... | f.write_i16(self.samples.as_mut_slice(), len);
f.close();
true
},
Err(e) => { println!("{}", e); false }
}
}
}
} | let mut file_ext = String::from_str(filename);
file_ext.push_str(".wav");
match SndFile::new_with_info(file_ext.as_slice(), Write, infos) {
Ok(mut f) => {
let len = self.samples.len() as i64; | random_line_split |
recorder.rs | // The MIT License (MIT)
//
// Copyright (c) 2013 Jeremy Letang (letang.jeremy@gmail.com)
//
// 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 without limitati... | {
ctxt: RecordContext,
stop_sender: Option<Sender<bool>>,
data_receiver: Option<Receiver<Vec<i16>>>,
samples: Vec<i16>
}
impl Recorder {
/// Create a new audio recorder
pub fn new(record_context: RecordContext) -> Recorder {
Recorder {
ctxt: record_context,
stop... | Recorder | identifier_name |
new_blog.rs | // Common routines and constants for creating a new silica site
use ::logger::{log_err, log_info};
use std::fs::{self, File};
use std::io::Write;
use git2::Repository;
use cmdline::{CUR_CONFIG_NAME, SITE_EXISTS, NOT_SILICA_SITE};
use chrono::*;
use ::errors::*;
// Macro to check if we are in a valid silica site
// Th... | (dir_path: &str) -> bool {
if let Ok(val) = fs::metadata(dir_path) {
return val.is_dir();
}
false
}
pub fn populate_directories(base_dir: &str) {
let config_file = join_str!(base_dir, "/silica.toml");
let content_dir = join_str!(base_dir, "/content");
let static_dir = join_str!(base_dir, "/static");
... | exists_dir | identifier_name |
new_blog.rs | // Common routines and constants for creating a new silica site
use ::logger::{log_err, log_info};
use std::fs::{self, File};
use std::io::Write;
use git2::Repository;
use cmdline::{CUR_CONFIG_NAME, SITE_EXISTS, NOT_SILICA_SITE};
use chrono::*;
use ::errors::*;
// Macro to check if we are in a valid silica site
// Th... | let _ = handle.write_all(post_metadata_end.as_bytes());
log_info(&format!("\nCreated a post at: {}\n", post_name));
}
Err(_) => bail!("Error creating post")
}
Ok(())
} | {
assert_valid_site!();
let mut post_name = post_name.to_owned();
if !post_name.contains(".md") {
post_name.push_str(".md");
}
let post_name = "./content/posts/".to_owned() + &post_name;
let local_time: DateTime<Local> = Local::now();
let local_time = local_time.format("%a %b %e %T %Y").to... | identifier_body |
new_blog.rs | // Common routines and constants for creating a new silica site
use ::logger::{log_err, log_info};
use std::fs::{self, File};
use std::io::Write;
use git2::Repository;
use cmdline::{CUR_CONFIG_NAME, SITE_EXISTS, NOT_SILICA_SITE};
use chrono::*;
use ::errors::*;
// Macro to check if we are in a valid silica site
// Th... |
Err(_) => bail!("Error creating post")
}
Ok(())
} | {
let _ = handle.write(post_timestamp.as_bytes());
let _ = handle.write(post_title.as_bytes());
let _ = handle.write(draft_flag.as_bytes());
let _ = handle.write_all(post_metadata_end.as_bytes());
log_info(&format!("\nCreated a post at: {}\n", post_name));
... | conditional_block |
new_blog.rs | // Common routines and constants for creating a new silica site
use ::logger::{log_err, log_info};
use std::fs::{self, File};
use std::io::Write;
use git2::Repository;
use cmdline::{CUR_CONFIG_NAME, SITE_EXISTS, NOT_SILICA_SITE};
use chrono::*;
use ::errors::*;
// Macro to check if we are in a valid silica site
// Th... |
pub fn create_new_site(site_name: &str) {
if exists_config(CUR_CONFIG_NAME) || exists_dir(site_name) {
return log_err(SITE_EXISTS);
}
let prefix = "./";
let base_dir = join_str!(prefix, site_name);
let repo = match Repository::init(&base_dir[..]) {
Ok(repo) => repo,
Err(e) =... | Err(why) => {
println!("{:?}", why);
}
}
} | random_line_split |
maybe_owned_vec.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 ... | (&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
self.as_slice().partial_cmp(other.as_slice())
}
}
impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
self.as_slice().cmp(other.as_slice())
}
}
impl<'a, T: PartialEq, V: AsSli... | partial_cmp | identifier_name |
maybe_owned_vec.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 ... |
}
impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> {
fn clone(&self) -> MaybeOwnedVector<'a, T> {
match *self {
Growable(ref v) => Growable(v.clone()),
Borrowed(v) => Borrowed(v)
}
}
}
impl<'a, T> Default for MaybeOwnedVector<'a, T> {
fn default() -> MaybeOwned... | {
self.as_slice().permutations()
} | identifier_body |
maybe_owned_vec.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 ... |
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
self.as_slice().partitioned(f)
}
fn permutations(&self) -> Permutations<T> {
self.as_slice().permutations()
}
}
impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> {
fn clone(&self) -> MaybeOwnedVector<'a, T> {
... | impl<'a,T:Clone> CloneSliceAllocPrelude<T> for MaybeOwnedVector<'a,T> {
/// Returns a copy of `self`.
fn to_vec(&self) -> Vec<T> {
self.as_slice().to_vec()
} | random_line_split |
map.rs | //! map provides functions around StringMap (HashMap<String, String>).
//!
//! # Example
//! ```
//! use sqlib::map::{to_map, update_from_map};
//!
//! let map = to_map("key1=2");
//! let mut integer = 1i32;
//!
//! update_from_map(&map, "key1", &mut integer);
//!
//! assert_eq!(integer, 2);
//! ```
use std::collectio... | /// let string = " key1=value1 key2=value2 ";
/// let map = to_map(string);
///
/// assert_eq!(map.get("key1").unwrap(), "value1");
/// assert_eq!(map.get("key2").unwrap(), "value2");
/// ```
pub fn to_map(string: &str) -> StringMap {
let pair_seperator = char::is_whitespace;
let key_value_seperator = '=';
... | ///
/// # Example
/// ```
/// use sqlib::map::to_map;
/// | random_line_split |
map.rs | //! map provides functions around StringMap (HashMap<String, String>).
//!
//! # Example
//! ```
//! use sqlib::map::{to_map, update_from_map};
//!
//! let map = to_map("key1=2");
//! let mut integer = 1i32;
//!
//! update_from_map(&map, "key1", &mut integer);
//!
//! assert_eq!(integer, 2);
//! ```
use std::collectio... | (string: &str) -> StringMap {
let pair_seperator = char::is_whitespace;
let key_value_seperator = '=';
let mut map = HashMap::new();
let pairs = string.split(pair_seperator);
for pair in pairs {
let kv: Vec<&str> = pair.splitn(2, key_value_seperator).collect();
if kv.len() < 2 {
... | to_map | identifier_name |
map.rs | //! map provides functions around StringMap (HashMap<String, String>).
//!
//! # Example
//! ```
//! use sqlib::map::{to_map, update_from_map};
//!
//! let map = to_map("key1=2");
//! let mut integer = 1i32;
//!
//! update_from_map(&map, "key1", &mut integer);
//!
//! assert_eq!(integer, 2);
//! ```
use std::collectio... |
/// This function gets the value to the key from the map, then parses it and mutates the given
/// pointer.
///
/// # Example
/// ```
/// use sqlib::map::{to_map, update_from_map};
///
/// let map = to_map("key1=2");
/// let mut integer = 1i32;
///
/// update_from_map(&map, "key1", &mut integer);
///
/// assert_eq!(i... | {
let pair_seperator = char::is_whitespace;
let key_value_seperator = '=';
let mut map = HashMap::new();
let pairs = string.split(pair_seperator);
for pair in pairs {
let kv: Vec<&str> = pair.splitn(2, key_value_seperator).collect();
if kv.len() < 2 {
continue;
}... | identifier_body |
map.rs | //! map provides functions around StringMap (HashMap<String, String>).
//!
//! # Example
//! ```
//! use sqlib::map::{to_map, update_from_map};
//!
//! let map = to_map("key1=2");
//! let mut integer = 1i32;
//!
//! update_from_map(&map, "key1", &mut integer);
//!
//! assert_eq!(integer, 2);
//! ```
use std::collectio... |
}
| {
let r: Result<T, _> = v.parse();
if let Ok(v) = r {
*value = v;
}
} | conditional_block |
bitv-perf-test.rs |
// Copyright 2012-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-M... | {
for _ in range(0, 10000) { bitv_test(); }
} | identifier_body | |
bitv-perf-test.rs | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate collections;
use collections::Bitv;
fn bitv_test() {
let mut v1 = ~Bit... | // Copyright 2012-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 | random_line_split | |
bitv-perf-test.rs |
// Copyright 2012-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-M... | () {
for _ in range(0, 10000) { bitv_test(); }
}
| main | identifier_name |
estimate.rs | use std::error::Error;
use std::fs::File;
use std::io;
use bio::stats::{LogProb, Prob};
use clap;
use csv;
use serde_json;
use libprosic;
use libprosic::estimation;
use libprosic::model;
use libprosic::model::AlleleFreq;
use call;
pub fn effective_mutation_rate(matches: &clap::ArgMatches) -> Result<(), Box<Error>> ... | }
| {
let call_bcf = matches.value_of("calls").unwrap();
let alpha = value_t!(matches, "alpha", f64).unwrap();
let events_list = matches.values_of("events").unwrap();
let vartype = matches.value_of("vartype").unwrap();
let min_len = value_t!(matches, "min-len", u32).ok();
let max_len = value_t!(matc... | identifier_body |
estimate.rs | use std::error::Error;
use std::fs::File;
use std::io;
use bio::stats::{LogProb, Prob};
use clap;
use csv;
use serde_json;
use libprosic;
use libprosic::estimation;
use libprosic::model;
use libprosic::model::AlleleFreq;
use call;
pub fn effective_mutation_rate(matches: &clap::ArgMatches) -> Result<(), Box<Error>> ... | (matches: &clap::ArgMatches) -> Result<(), Box<Error>> {
let call_bcf = matches.value_of("calls").unwrap();
let alpha = value_t!(matches, "alpha", f64).unwrap();
let events_list = matches.values_of("events").unwrap();
let vartype = matches.value_of("vartype").unwrap();
let min_len = value_t!(matches... | fdr | identifier_name |
estimate.rs | use std::error::Error;
use std::fs::File;
use std::io;
use bio::stats::{LogProb, Prob};
use clap;
use csv;
use serde_json;
use libprosic;
use libprosic::estimation;
use libprosic::model;
use libprosic::model::AlleleFreq;
use call;
pub fn effective_mutation_rate(matches: &clap::ArgMatches) -> Result<(), Box<Error>> ... |
Ok(())
}
struct DummyEvent {
pub name: String,
}
impl libprosic::Event for DummyEvent {
fn name(&self) -> &str {
&self.name
}
}
/// Parse `VariantType` from command line arguments.
pub fn parse_vartype(
vartype: &str,
min_len: Option<u32>,
max_len: Option<u32>,
) -> Result<model:... | {
let mut f = try!(File::create(path));
serde_json::to_writer(&mut f, &estimate)?;
} | conditional_block |
estimate.rs | use std::error::Error;
use std::fs::File;
use std::io;
use bio::stats::{LogProb, Prob};
use clap;
use csv;
use serde_json;
use libprosic;
use libprosic::estimation;
use libprosic::model;
use libprosic::model::AlleleFreq;
use call;
pub fn effective_mutation_rate(matches: &clap::ArgMatches) -> Result<(), Box<Error>> ... | max_len: Option<u32>,
) -> Result<model::VariantType, Box<Error>> {
Ok(match (vartype, min_len, max_len) {
("SNV", _, _) => model::VariantType::SNV,
("INS", Some(min_len), Some(max_len)) => {
model::VariantType::Insertion(Some(min_len..max_len))
}
("DEL", Some(min_len... |
/// Parse `VariantType` from command line arguments.
pub fn parse_vartype(
vartype: &str,
min_len: Option<u32>, | random_line_split |
ini_files.rs | // Adapted from https://marwes.github.io/2015/08/28/combine-1.0.0.html
#[macro_use]
extern crate peggler;
use std::collections::HashMap;
use peggler::{ParseError, ParseResult};
#[derive(PartialEq, Debug)]
pub struct Ini {
pub global: HashMap<String, String>,
pub sections: HashMap<String, HashMap<String, Stri... |
#[test]
fn test_ini() {
let input = r#"
key=value
[section]
key1=value1; Comment
key2=value2
"#;
let mut expected = Ini {
global: HashMap::new(),
sections: HashMap::new()
};
expected.global.insert("key".to_string(), "value".to_string());
le... | {
let input = "[section]\nkey1=value1\nkey2=value2";
let mut props = HashMap::new();
props.insert("key1".to_string(), "value1".to_string());
props.insert("key2".to_string(), "value2".to_string());
assert_eq!(
section(input),
Ok((("section".to_string(), props), "")));
} | identifier_body |
ini_files.rs | // Adapted from https://marwes.github.io/2015/08/28/combine-1.0.0.html
#[macro_use]
extern crate peggler;
use std::collections::HashMap;
use peggler::{ParseError, ParseResult};
#[derive(PartialEq, Debug)]
pub struct Ini {
pub global: HashMap<String, String>,
pub sections: HashMap<String, HashMap<String, Stri... | () {
let input = "[section]\nkey1=value1\nkey2=value2";
let mut props = HashMap::new();
props.insert("key1".to_string(), "value1".to_string());
props.insert("key2".to_string(), "value2".to_string());
assert_eq!(
section(input),
Ok((("section".to_string(), props), "")));
}
#[test]
... | test_section | identifier_name |
ini_files.rs | // Adapted from https://marwes.github.io/2015/08/28/combine-1.0.0.html
#[macro_use]
extern crate peggler;
use std::collections::HashMap;
use peggler::{ParseError, ParseResult};
#[derive(PartialEq, Debug)]
pub struct Ini {
pub global: HashMap<String, String>,
pub sections: HashMap<String, HashMap<String, Stri... | props: properties
=> { (title.into_iter().collect(), props) });
rule!(ini:Ini = whitespace global:properties sections:section*
=> {Ini { global: global,
sections: sections.into_iter().collect()
}});
#[test]
fn test_property() {
assert_eq!(
property("key=value")... | title: (["["] title:((!(["]"]) any_char))+ ["]"] => { title })
whitespace | random_line_split |
ui.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/. */
//! Specified types for UI properties.
use crate::parser::{Parse, ParserContext};
use crate::values::generics::u... | {
Auto,
Text,
#[parse(aliases = "-moz-none")]
None,
/// Force selection of all children.
All,
}
| UserSelect | identifier_name |
ui.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/. */
//! Specified types for UI properties.
use crate::parser::{Parse, ParserContext};
use crate::values::generics::u... |
}
/// The specified value for the `user-select` property.
///
/// https://drafts.csswg.org/css-ui-4/#propdef-user-select
#[allow(missing_docs)]
#[derive(
Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
#[repr(u8)]
pub enum ... | {
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
return Ok(generics::ScrollbarColor::Auto);
}
Ok(generics::ScrollbarColor::Colors {
thumb: Color::parse(context, input)?,
track: Color::parse(context, input)?,
})
} | identifier_body |
ui.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/. */
//! Specified types for UI properties.
| use crate::values::{Auto, Either};
use cssparser::Parser;
use std::fmt::{self, Write};
use style_traits::cursor::CursorKind;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
/// auto | <color>
pub type ColorOrAuto = Either<Color, Auto>;
/// A specified value for the `cursor` property.
pub type C... | use crate::parser::{Parse, ParserContext};
use crate::values::generics::ui as generics;
use crate::values::specified::color::Color;
use crate::values::specified::url::SpecifiedImageUrl;
use crate::values::specified::Number; | random_line_split |
selectors.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt;
use crate::python::TypeId;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialOrd, Hash, PartialEq)]
pub struct Get {
pub output: TypeId,
pub input: TypeId,
}
impl fmt::Di... |
}
| {
match self {
DependencyKey::JustSelect(s) => write!(f, "{}", s.product),
DependencyKey::JustGet(g) => write!(f, "{}", g),
}
} | identifier_body |
selectors.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt;
use crate::python::TypeId;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialOrd, Hash, PartialEq)]
pub struct Get {
pub output: TypeId,
pub input: TypeId,
}
impl fmt::Di... | match self {
DependencyKey::JustGet(ref g) => Some(g.input),
DependencyKey::JustSelect(_) => None,
}
}
}
impl fmt::Display for DependencyKey {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
DependencyKey::JustSelect(s) => write!(f, "{}", s.product),
... | }
fn provided_param(&self) -> Option<TypeId> { | random_line_split |
selectors.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt;
use crate::python::TypeId;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialOrd, Hash, PartialEq)]
pub struct | {
pub output: TypeId,
pub input: TypeId,
}
impl fmt::Display for Get {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "Get({}, {})", self.output, self.input)
}
}
#[derive(Clone, Copy, Eq, Ord, PartialOrd, Hash, PartialEq)]
pub struct Select {
pub product: TypeId,
}
impl Se... | Get | identifier_name |
checkerboard.rs | // Copyright (c) 2017 The Noise-rs Developers.
//
// 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 http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... |
}
fn calculate_checkerboard(point: &[f64], size: usize) -> f64 {
let result = point
.iter()
.map(|&a| a.floor() as usize)
.fold(0, |a, b| (a & size) ^ (b & size));
if result > 0 { -1.0 } else { 1.0 }
}
| {
calculate_checkerboard(&point, self.size)
} | identifier_body |
checkerboard.rs | // Copyright (c) 2017 The Noise-rs Developers.
//
// 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 http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... | calculate_checkerboard(&point, self.size)
}
}
impl NoiseFn<Point3<f64>> for Checkerboard {
fn get(&self, point: Point3<f64>) -> f64 {
calculate_checkerboard(&point, self.size)
}
}
impl NoiseFn<Point4<f64>> for Checkerboard {
fn get(&self, point: Point4<f64>) -> f64 {
calculate_... |
// These impl's should be made generic over Point, but there is no higher Point
// type. Keep the code the same anyway.
impl NoiseFn<Point2<f64>> for Checkerboard {
fn get(&self, point: Point2<f64>) -> f64 { | random_line_split |
checkerboard.rs | // Copyright (c) 2017 The Noise-rs Developers.
//
// 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 http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... |
}
| { 1.0 } | conditional_block |
checkerboard.rs | // Copyright (c) 2017 The Noise-rs Developers.
//
// 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 http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... | (&self, point: Point2<f64>) -> f64 {
calculate_checkerboard(&point, self.size)
}
}
impl NoiseFn<Point3<f64>> for Checkerboard {
fn get(&self, point: Point3<f64>) -> f64 {
calculate_checkerboard(&point, self.size)
}
}
impl NoiseFn<Point4<f64>> for Checkerboard {
fn get(&self, point: Poi... | get | identifier_name |
issue-14865.rs | // Copyright 2012-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... | {
Foo(uint),
Bar(bool)
}
fn main() {
let x = match Foo(42) {
Foo(..) => 1i,
_ if true => 0,
Bar(..) => fail!("Oh dear")
};
assert_eq!(x, 1);
let x = match Foo(42) {
_ if true => 0i,
Foo(..) => 1,
Bar(..) => fail!("Oh dear")
};
assert_eq!... | X | identifier_name |
issue-14865.rs | // Copyright 2012-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... |
let x = match Foo(42) {
_ if true => 0i,
Foo(..) => 1,
Bar(..) => fail!("Oh dear")
};
assert_eq!(x, 0);
} | _ if true => 0,
Bar(..) => fail!("Oh dear")
};
assert_eq!(x, 1); | random_line_split |
import-glob-circular.rs | // Copyright 2012-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... |
}
mod test {
use circ1::*;
fn test() { f1066(); }
}
| { return 1; } | identifier_body |
import-glob-circular.rs | // Copyright 2012-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... | mod circ1 {
pub use circ2::f2;
pub fn f1() { println!("f1"); }
pub fn common() -> usize { return 0; }
}
mod circ2 {
pub use circ1::f1;
pub fn f2() { println!("f2"); }
pub fn common() -> usize { return 1; }
}
mod test {
use circ1::*;
fn test() { f1066(); }
} | random_line_split | |
import-glob-circular.rs | // Copyright 2012-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... | () { println!("f1"); }
pub fn common() -> usize { return 0; }
}
mod circ2 {
pub use circ1::f1;
pub fn f2() { println!("f2"); }
pub fn common() -> usize { return 1; }
}
mod test {
use circ1::*;
fn test() { f1066(); }
}
| f1 | identifier_name |
sepcomp-fns-backwards.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 main() {
assert_eq!(one(), 1);
assert_eq!(a::two(), 2);
assert_eq!(b::three(), 3);
}
| {
1
} | identifier_body |
sepcomp-fns-backwards.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 ... |
// Test references to items that haven't been translated yet.
// Generate some code in the first compilation unit before declaring any
// modules. This ensures that the first module doesn't go into the same
// compilation unit as the top-level module.
fn pad() -> usize { 0 }
mod b {
pub fn three() -> usize {
... | // except according to those terms.
// ignore-bitrig
// compile-flags: -C codegen-units=3 | random_line_split |
sepcomp-fns-backwards.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 ... | () -> usize {
1
}
fn main() {
assert_eq!(one(), 1);
assert_eq!(a::two(), 2);
assert_eq!(b::three(), 3);
}
| one | identifier_name |
task-comm-10.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 ... | (c: &comm::Chan<comm::Chan<~str>>) {
let (p, ch) = comm::stream();
c.send(ch);
let mut a;
let mut b;
a = p.recv();
assert!(a == ~"A");
error!("{:?}", a);
b = p.recv();
assert!(b == ~"B");
error!("{:?}", b);
}
pub fn main() {
let (p, ch) = comm::stream();
let _child = ta... | start | identifier_name |
task-comm-10.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 b;
a = p.recv();
assert!(a == ~"A");
error!("{:?}", a);
b = p.recv();
assert!(b == ~"B");
error!("{:?}", b);
}
pub fn main() {
let (p, ch) = comm::stream();
let _child = task::spawn(proc() start(&ch) );
let c = p.recv();
c.send(~"A");
c.send(~"B");
task::des... |
let mut a; | random_line_split |
task-comm-10.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() {
let (p, ch) = comm::stream();
let _child = task::spawn(proc() start(&ch) );
let c = p.recv();
c.send(~"A");
c.send(~"B");
task::deschedule();
}
| {
let (p, ch) = comm::stream();
c.send(ch);
let mut a;
let mut b;
a = p.recv();
assert!(a == ~"A");
error!("{:?}", a);
b = p.recv();
assert!(b == ~"B");
error!("{:?}", b);
} | identifier_body |
lib.rs | //! # Building a [`WindowedContext<T>`]
//!
//! A [`WindowedContext<T>`] is composed of a [`Window`] and an OpenGL
//! [`Context`].
//!
//! Due to some operating-system-specific quirks, glutin prefers control over
//! the order of creation of the [`Context`] and [`Window`]. Here is an example
//! of building a [`Window... | {
/// The classical OpenGL. Available on Windows, Unix operating systems,
/// OS/X.
OpenGl,
/// OpenGL embedded system. Available on Unix operating systems, Android.
OpenGlEs,
/// OpenGL for the web. Very similar to OpenGL ES.
WebGl,
}
/// Describes the requested OpenGL [`Context`] profile... | Api | identifier_name |
lib.rs | //!
//! # Building a [`WindowedContext<T>`]
//!
//! A [`WindowedContext<T>`] is composed of a [`Window`] and an OpenGL
//! [`Context`].
//!
//! Due to some operating-system-specific quirks, glutin prefers control over
//! the order of creation of the [`Context`] and [`Window`]. Here is an example
//! of building a [`Wi... | ///
/// Will panic if `samples` is not a power of two.
#[inline]
pub fn with_multisampling(mut self, samples: u16) -> Self {
self.pf_reqs.multisampling = match samples {
0 => None,
_ => {
assert!(samples.is_power_of_two());
Some(samples)
... |
/// Sets the multisampling level to request. A value of `0` indicates that
/// multisampling must not be enabled.
///
/// # Panic | random_line_split |
pool.rs | use wio::com::ComPtr;
use dxguid;
use std::ptr;
use std::os::raw::c_void;
use winapi;
use hal::pool;
use command::CommandBuffer;
use {Backend, CmdSignatures};
pub struct RawCommandPool {
pub(crate) inner: ComPtr<winapi::ID3D12CommandAllocator>,
pub(crate) device: ComPtr<winapi::ID3D12Device>,
pub(crate) l... | self.inner.clone(),
self.signatures.clone(),
))
.collect()
}
unsafe fn free(&mut self, _cbufs: Vec<CommandBuffer>) {
// Just let the command buffers drop
}
}
pub struct SubpassCommandPool;
impl pool::SubpassCommandPool<Backend> for SubpassComm... |
fn allocate(&mut self, num: usize) -> Vec<CommandBuffer> {
(0..num)
.map(|_| CommandBuffer::new(
self.create_command_list(), | random_line_split |
pool.rs | use wio::com::ComPtr;
use dxguid;
use std::ptr;
use std::os::raw::c_void;
use winapi;
use hal::pool;
use command::CommandBuffer;
use {Backend, CmdSignatures};
pub struct RawCommandPool {
pub(crate) inner: ComPtr<winapi::ID3D12CommandAllocator>,
pub(crate) device: ComPtr<winapi::ID3D12Device>,
pub(crate) l... | (&mut self) {
unsafe { self.inner.Reset(); }
}
fn allocate(&mut self, num: usize) -> Vec<CommandBuffer> {
(0..num)
.map(|_| CommandBuffer::new(
self.create_command_list(),
self.inner.clone(),
self.signatures.clone(),
))
... | reset | identifier_name |
pool.rs | use wio::com::ComPtr;
use dxguid;
use std::ptr;
use std::os::raw::c_void;
use winapi;
use hal::pool;
use command::CommandBuffer;
use {Backend, CmdSignatures};
pub struct RawCommandPool {
pub(crate) inner: ComPtr<winapi::ID3D12CommandAllocator>,
pub(crate) device: ComPtr<winapi::ID3D12Device>,
pub(crate) l... |
}
pub struct SubpassCommandPool;
impl pool::SubpassCommandPool<Backend> for SubpassCommandPool {}
| {
// Just let the command buffers drop
} | identifier_body |
pool.rs | use wio::com::ComPtr;
use dxguid;
use std::ptr;
use std::os::raw::c_void;
use winapi;
use hal::pool;
use command::CommandBuffer;
use {Backend, CmdSignatures};
pub struct RawCommandPool {
pub(crate) inner: ComPtr<winapi::ID3D12CommandAllocator>,
pub(crate) device: ComPtr<winapi::ID3D12Device>,
pub(crate) l... |
unsafe { ComPtr::new(command_list) }
};
// Close command list as they are initiated as recording.
// But only one command list can be recording for each allocator
unsafe { command_list.Close(); }
command_list
}
}
unsafe impl Send for RawCommandPool { }
impl ... | {
error!("error on command list creation: {:x}", hr);
} | conditional_block |
signer.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity 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 lat... | #[rpc(name = "signer_rejectRequest")]
fn reject_request(&self, U256) -> Result<bool, Error>;
/// Generates new authorization token.
#[rpc(name = "signer_generateAuthorizationToken")]
fn generate_token(&self) -> Result<String, Error>;
/// Generates new web proxy access token.
#[rpc(name = "signer_generat... | fn confirm_request_raw(&self, U256, Bytes) -> Result<ConfirmationResponse, Error>;
/// Reject the confirmation request. | random_line_split |
kqueue.rs | use std::os::unix::io::RawFd;
use std::collections::HashMap;
use std::slice;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::os::unix::io::AsRawFd;
use nix::sys::event::{ev_set, kqueue, kevent, KEvent, EventFilter, EventFlag, FilterFlag};
use libc::{uintptr_t, intptr_t};
use std::io::Result... | (&mut self) {
for e in self.eventlist.drain(..) {
let event = event_from_filter(e.filter());
let new_notification = Notification {
id: e.udata() as usize,
event: event.clone()
};
let mut notification = self.notifications.entry(e.id... | coalesce_events | identifier_name |
kqueue.rs | use std::os::unix::io::RawFd;
use std::collections::HashMap;
use std::slice;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::os::unix::io::AsRawFd;
use nix::sys::event::{ev_set, kqueue, kevent, KEvent, EventFilter, EventFlag, FilterFlag};
use libc::{uintptr_t, intptr_t};
use std::io::Result... | {
let mut flags = EventFlag::EV_ADD;
if !recurring {
flags |= EventFlag::EV_ONESHOT;
}
let ev = KEvent::new(
id as uintptr_t,
EventFilter::EVFILT_TIMER,
flags,
FilterFlag::empty(), // timeouts are in ms by default
timeout as intptr_t,
id as UserDat... | identifier_body | |
kqueue.rs | use std::os::unix::io::RawFd;
use std::collections::HashMap;
use std::slice;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::os::unix::io::AsRawFd;
use nix::sys::event::{ev_set, kqueue, kevent, KEvent, EventFilter, EventFlag, FilterFlag};
use libc::{uintptr_t, intptr_t};
use std::io::Result... | Ok(self.notifications.drain().map(|(_, v)| v).collect())
}
// Combine read and write events for the same socket into a single notification.
fn coalesce_events(&mut self) {
for e in self.eventlist.drain(..) {
let event = event_from_filter(e.filter());
let new_notifica... | random_line_split | |
owned.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
| use std::sync::Arc;
use anyhow::Result;
use async_trait::async_trait;
use context::CoreContext;
use mononoke_types::ChangesetId;
use crate::idmap::IdMap;
use crate::read_only::ReadOnlySegmentedChangelog;
use crate::{segmented_changelog_delegate, SegmentedChangelog};
use crate::{CloneData, InProcessIdDag, Location};
... | use std::collections::HashMap; | random_line_split |
owned.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::Result;
use async_trait::async_trait;
use context::CoreContext;
use monono... | (iddag: InProcessIdDag, idmap: Arc<dyn IdMap>) -> Self {
Self { iddag, idmap }
}
}
segmented_changelog_delegate!(OwnedSegmentedChangelog, |&self, ctx: &CoreContext| {
ReadOnlySegmentedChangelog::new(&self.iddag, self.idmap.clone())
});
| new | identifier_name |
owned.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::Result;
use async_trait::async_trait;
use context::CoreContext;
use monono... |
}
segmented_changelog_delegate!(OwnedSegmentedChangelog, |&self, ctx: &CoreContext| {
ReadOnlySegmentedChangelog::new(&self.iddag, self.idmap.clone())
});
| {
Self { iddag, idmap }
} | identifier_body |
restyle_damage.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/. */
//! The restyle damage is a hint that tells layout which kind of operations may
//! be needed in presence of incre... |
/// Supposing the *parent* of a flow with the given `position` property has
/// this damage, returns the damage that we should add to this flow.
pub fn damage_for_child(self,
parent_is_absolutely_positioned: bool,
child_is_absolutely_positioned: bool... | {
if child_is_absolutely_positioned {
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_CONTENT)
} else {
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_C... | identifier_body |
restyle_damage.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/. */
//! The restyle damage is a hint that tells layout which kind of operations may
//! be needed in presence of incre... | () -> ServoRestyleDamage {
REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW |
RECONSTRUCT_FLOW
}
/// Returns a bitmask indicating that the frame needs to be reconstructed.
pub fn reconstruct() -> ServoRestyleDamage {
RECONSTRUCT_FLOW
}
... | rebuild_and_reflow | identifier_name |
restyle_damage.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/. */
//! The restyle damage is a hint that tells layout which kind of operations may
//! be needed in presence of incre... |
}
}
/// Servo doesn't implement this optimization.
pub fn handled_for_descendants(self) -> Self {
Self::empty()
}
}
impl Default for ServoRestyleDamage {
fn default() -> Self {
Self::empty()
}
}
impl fmt::Display for ServoRestyleDamage {
fn fmt(&self, f: &mut fmt:... | {
// TODO(pcwalton): Take floatedness into account.
self & (REPAINT | REPOSITION | REFLOW)
} | conditional_block |
restyle_damage.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/. */
//! The restyle damage is a hint that tells layout which kind of operations may
//! be needed in presence of incre... | get_position.align_self
]) || add_if_not_equal!(old, new, damage,
[REPAINT, REPOSITION, STORE_OVERFLOW, REFLOW_OUT_OF_FLOW], [
get_position.top, get_position.left,
get_position.right, get_position.bottom,
get_effects.opacity,
get_box.transform, get... | get_position.flex_grow,
get_position.flex_shrink, | random_line_split |
branch.rs | use cpu::{self, Cpu, Version};
use cpu::interpreter_arm as arm;
use bitutils::sign_extend32;
fn instr_branch_exchange<V: Version>(cpu: &mut Cpu<V>, data: arm::Bx::Bf, link: bool) -> cpu::InstrStatus {
if!cpu::cond_passed(data.cond.get(), &cpu.cpsr) {
return cpu::InstrStatus::InBlock;
}
let addr = ... | <V: Version>(cpu: &mut Cpu<V>, data: arm::Blx2::Bf) -> cpu::InstrStatus {
instr_branch_exchange(cpu, arm::Bx::new(data.val), true)
}
pub fn bx<V: Version>(cpu: &mut Cpu<V>, data: arm::Bx::Bf) -> cpu::InstrStatus {
instr_branch_exchange(cpu, data, false)
}
pub fn mod_blx<V: Version>(cpu: &mut Cpu<V>, data: arm... | blx | identifier_name |
branch.rs | use cpu::{self, Cpu, Version};
use cpu::interpreter_arm as arm;
use bitutils::sign_extend32;
fn instr_branch_exchange<V: Version>(cpu: &mut Cpu<V>, data: arm::Bx::Bf, link: bool) -> cpu::InstrStatus {
if!cpu::cond_passed(data.cond.get(), &cpu.cpsr) {
return cpu::InstrStatus::InBlock;
}
let addr = ... | {
let signed_imm_24 = data.signed_imm_24.get();
let h_bit = data.h_bit.get();
cpu.regs[14] = cpu.regs[15] - 4;
cpu.cpsr.thumb_bit.set(1);
let pc = cpu.regs[15];
cpu.branch((pc as i32 + (sign_extend32(signed_imm_24, 24) << 2)) as u32 + (h_bit << 1));
cpu::InstrStatus::Branched
} | identifier_body | |
branch.rs | use cpu::{self, Cpu, Version};
use cpu::interpreter_arm as arm;
use bitutils::sign_extend32;
fn instr_branch_exchange<V: Version>(cpu: &mut Cpu<V>, data: arm::Bx::Bf, link: bool) -> cpu::InstrStatus {
if!cpu::cond_passed(data.cond.get(), &cpu.cpsr) {
return cpu::InstrStatus::InBlock;
}
let addr = ... |
pub fn mod_blx<V: Version>(cpu: &mut Cpu<V>, data: arm::ModBlx::Bf) -> cpu::InstrStatus {
let signed_imm_24 = data.signed_imm_24.get();
let h_bit = data.h_bit.get();
cpu.regs[14] = cpu.regs[15] - 4;
cpu.cpsr.thumb_bit.set(1);
let pc = cpu.regs[15];
cpu.branch((pc as i32 + (sign_extend32(signe... | } | random_line_split |
branch.rs | use cpu::{self, Cpu, Version};
use cpu::interpreter_arm as arm;
use bitutils::sign_extend32;
fn instr_branch_exchange<V: Version>(cpu: &mut Cpu<V>, data: arm::Bx::Bf, link: bool) -> cpu::InstrStatus {
if!cpu::cond_passed(data.cond.get(), &cpu.cpsr) |
let addr = cpu.regs[data.rm.get() as usize];
if link {
cpu.regs[14] = cpu.regs[15] - 4;
}
cpu.cpsr.thumb_bit.set(bit!(addr, 0));
cpu.branch(addr & 0xFFFFFFFE);
cpu::InstrStatus::Branched
}
pub fn bbl<V: Version>(cpu: &mut Cpu<V>, data: arm::Bbl::Bf) -> cpu::InstrStatus {
if!cpu... | {
return cpu::InstrStatus::InBlock;
} | conditional_block |
foo.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct Foo {
... | random_line_split | |
foo.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 ... |
}
trait Tr2<X, Y: Tr> {
fn squid(&self, y: &Y, z: Self) -> Box<X>;
}
impl Tr2<Foo, Foo> for Foo {
fn squid(&self, y: &Foo, z: Foo) -> Box<Foo> {
box Foo { f: y.f + z.f + self.f }
}
}
enum En {
Var1,
Var2,
Var3(int, int, Foo)
}
fn main() {
let x = Foo { f: 237 };
let _f = x.b... | {
Foo{ f: self.f + x.f }
} | identifier_body |
foo.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 ... | (&self, y: &Foo, z: Foo) -> Box<Foo> {
box Foo { f: y.f + z.f + self.f }
}
}
enum En {
Var1,
Var2,
Var3(int, int, Foo)
}
fn main() {
let x = Foo { f: 237 };
let _f = x.bar();
let en = En::Var2;
let _ = match en {
En::Var1 => x.bar(),
En::Var2 => 34,
En:... | squid | identifier_name |
day02.rs | struct Keypad {
grid: KeyGrid,
cursor: (usize, usize),
}
type KeyGrid = Vec<Vec<Option<char>>>;
impl Keypad {
fn simple() -> Keypad {
let grid: KeyGrid = vec![vec![Some('1'), Some('2'), Some('3')],
vec![Some('4'), Some('5'), Some('6')],
... | {
let digit_commands: Vec<&str> = input.split("\n").collect();
let mut code: Vec<char> = vec![];
for command_set in digit_commands.clone() {
let mut keypad = Keypad::simple();
let digit = keypad.process(command_set);
code.push(digit);
}
println!("Simple Code is {:?}", code);... | identifier_body | |
day02.rs | struct Keypad {
grid: KeyGrid,
cursor: (usize, usize),
}
type KeyGrid = Vec<Vec<Option<char>>>;
impl Keypad {
fn simple() -> Keypad {
let grid: KeyGrid = vec![vec![Some('1'), Some('2'), Some('3')],
vec![Some('4'), Some('5'), Some('6')],
... | let digit = keypad.process(command_set);
code.push(digit);
}
println!("Simple Code is {:?}", code);
code.clear();
for command_set in digit_commands.clone() {
let mut keypad = Keypad::complicated();
let digit = keypad.process(command_set);
code.push(digit);
}
... | random_line_split | |
day02.rs | struct Keypad {
grid: KeyGrid,
cursor: (usize, usize),
}
type KeyGrid = Vec<Vec<Option<char>>>;
impl Keypad {
fn simple() -> Keypad {
let grid: KeyGrid = vec![vec![Some('1'), Some('2'), Some('3')],
vec![Some('4'), Some('5'), Some('6')],
... | (&mut self, commands: &str) -> char {
let mut x = self.cursor.1 as isize;
let mut y = self.cursor.0 as isize;
for step in commands.chars() {
match step {
'U' => {
let (x_, y_) = self.bound(x, y - 1).unwrap_or((x, y));
x = x_;
... | process | identifier_name |
role-playing-game.rs | use role_playing_game::*;
#[test]
fn test_reviving_dead_player() {
let dead_player = Player {
health: 0,
mana: Some(0),
level: 34,
};
let revived_player = dead_player
.revive()
.expect("reviving a dead player must return Some(player)");
assert_eq!(revived_player.he... | assert_eq!(accomplished_wizard.cast_spell(MANA_COST), MANA_COST * 2);
assert_eq!(accomplished_wizard.health, HEALTH);
assert_eq!(accomplished_wizard.mana, Some(MANA - MANA_COST));
assert_eq!(accomplished_wizard.level, LEVEL);
}
#[test]
#[ignore]
fn test_cast_spell_with_insufficient_mana() {
let mut... | health: HEALTH,
mana: Some(MANA),
level: LEVEL,
};
| random_line_split |
role-playing-game.rs | use role_playing_game::*;
#[test]
fn test_reviving_dead_player() {
let dead_player = Player {
health: 0,
mana: Some(0),
level: 34,
};
let revived_player = dead_player
.revive()
.expect("reviving a dead player must return Some(player)");
assert_eq!(revived_player.he... | () {
const MANA_COST: u32 = 10;
let mut underleveled_player = Player {
health: 87,
mana: None,
level: 6,
};
let clone = Player {
..underleveled_player
};
assert_eq!(underleveled_player.cast_spell(MANA_COST), 0);
assert_eq!(underleveled_player.health, clone.h... | test_cast_spell_with_no_mana_pool | identifier_name |
role-playing-game.rs | use role_playing_game::*;
#[test]
fn test_reviving_dead_player() {
let dead_player = Player {
health: 0,
mana: Some(0),
level: 34,
};
let revived_player = dead_player
.revive()
.expect("reviving a dead player must return Some(player)");
assert_eq!(revived_player.he... |
#[test]
#[ignore]
fn test_cast_spell_with_insufficient_mana() {
let mut no_mana_wizard = Player {
health: 56,
mana: Some(2),
level: 22,
};
// we want to clone so we can compare before-and-after effects of casting the spell,
// but we don't want to introduce that concept to the... | {
const HEALTH: u32 = 99;
const MANA: u32 = 100;
const LEVEL: u32 = 100;
const MANA_COST: u32 = 3;
let mut accomplished_wizard = Player {
health: HEALTH,
mana: Some(MANA),
level: LEVEL,
};
assert_eq!(accomplished_wizard.cast_spell(MANA_COST), MANA_COST * 2);
ass... | identifier_body |
mod.rs | use std::collections::{HashMap, BTreeMap};
use std::f64;
use std::path::PathBuf;
use std::process::Command;
use chrono::NaiveDate;
// use std::process::Command;
use postgres::Connection;
use postgres::params::IntoConnectParams;
use nickel::{Nickel, HttpRouter, Router};
use super::data_structs::main_page_data::MainPa... | (&mut self, new_file: PathBuf) {
self.data_file = Some(new_file);
}
pub fn init(&mut self) {
// compile sass
// try to get file names
let temp_params = self.scss_params.clone();
let styles_dir = match temp_params.dir {
Some(d) => d,
None => "styles... | add_data_file | identifier_name |
mod.rs | use std::collections::{HashMap, BTreeMap};
use std::f64;
use std::path::PathBuf;
use std::process::Command;
use chrono::NaiveDate;
// use std::process::Command;
use postgres::Connection;
use postgres::params::IntoConnectParams;
use nickel::{Nickel, HttpRouter, Router};
use super::data_structs::main_page_data::MainPa... |
pub fn init(&mut self) {
// compile sass
// try to get file names
let temp_params = self.scss_params.clone();
let styles_dir = match temp_params.dir {
Some(d) => d,
None => "styles".to_owned(),
};
let scss_file = match temp_params.scss_file {
... | {
self.data_file = Some(new_file);
} | identifier_body |
mod.rs | use std::collections::{HashMap, BTreeMap};
use std::f64;
use std::path::PathBuf;
use std::process::Command;
use chrono::NaiveDate;
// use std::process::Command;
use postgres::Connection;
use postgres::params::IntoConnectParams;
use nickel::{Nickel, HttpRouter, Router};
use super::data_structs::main_page_data::MainPa... | fn main_page(&self) -> MainPageData {
if self.conn.is_none() {
panic!("No connection");
}
MainPageData { countries: Vec::new() }
}
}
impl ScssParams {
fn new() -> ScssParams {
ScssParams {
dir: None,
scss_file: None,
css_file: ... |
self.server.listen("127.0.0.1:6767");
} | random_line_split |
lib.rs | //! A library for creating and modifying Tree structures.
//!
//! ## Overview
//! In this implementation, the `Tree` owns all of the `Node`s and all inter-`Node` relationships
//! are managed with `NodeId`s.
//!
//! `Tree`s in this library are "just" trees. They do not allow cycles. They do not allow
//! the creation... | //! use id_tree::InsertBehavior::*;
//!
//! // 0
//! // / \
//! // 1 2
//! // / \
//! // 3 4
//! let mut tree: Tree<i32> = TreeBuilder::new()
//! .with_node_capacity(5)
//! .build();
//!
//! let root_id: NodeId = tree.insert(Node::new(0), AsRoot).unwrap()... | //!
//! fn main() { | random_line_split |
lib.rs | //! A library for creating and modifying Tree structures.
//!
//! ## Overview
//! In this implementation, the `Tree` owns all of the `Node`s and all inter-`Node` relationships
//! are managed with `NodeId`s.
//!
//! `Tree`s in this library are "just" trees. They do not allow cycles. They do not allow
//! the creation... | {
tree_id: ProcessUniqueId,
index: usize,
}
| NodeId | identifier_name |
wav.rs | use std::{fs::File, path::PathBuf, usize};
use structopt::StructOpt;
use vtx::{player::PrecisePlayer, Vtx};
#[derive(StructOpt)]
pub struct ConvertWav {
/// `*.vtx` input file path
#[structopt(short, long)]
input: PathBuf,
/// `*.wav` output file path
#[structopt(short, long)]
output: PathBuf,
... |
pos += samples_generated;
buffer.resize(pos + CHUNK_SIZE, 0);
}
buffer.truncate(pos);
let wav_header = wav::Header::new(
wav::WAV_FORMAT_PCM,
CHANNEL_COUNT as u16,
SAMPLE_RATE as u32,
BITS_PER_SAMPLE as u16,
);
... | {
break;
} | conditional_block |
wav.rs | use std::{fs::File, path::PathBuf, usize};
use structopt::StructOpt;
use vtx::{player::PrecisePlayer, Vtx};
#[derive(StructOpt)]
pub struct ConvertWav {
/// `*.vtx` input file path
#[structopt(short, long)]
input: PathBuf,
/// `*.wav` output file path
#[structopt(short, long)]
output: PathBuf,
... |
let wav_header = wav::Header::new(
wav::WAV_FORMAT_PCM,
CHANNEL_COUNT as u16,
SAMPLE_RATE as u32,
BITS_PER_SAMPLE as u16,
);
let mut output_file = File::create(self.output)?;
wav::write(
wav_header,
&wav::BitDepth:... | random_line_split | |
wav.rs | use std::{fs::File, path::PathBuf, usize};
use structopt::StructOpt;
use vtx::{player::PrecisePlayer, Vtx};
#[derive(StructOpt)]
pub struct | {
/// `*.vtx` input file path
#[structopt(short, long)]
input: PathBuf,
/// `*.wav` output file path
#[structopt(short, long)]
output: PathBuf,
}
impl ConvertWav {
pub fn execute(self) -> Result<(), anyhow::Error> {
const CHUNK_SIZE: usize = 16 * 64000;
const SAMPLE_RATE: u... | ConvertWav | identifier_name |
wav.rs | use std::{fs::File, path::PathBuf, usize};
use structopt::StructOpt;
use vtx::{player::PrecisePlayer, Vtx};
#[derive(StructOpt)]
pub struct ConvertWav {
/// `*.vtx` input file path
#[structopt(short, long)]
input: PathBuf,
/// `*.wav` output file path
#[structopt(short, long)]
output: PathBuf,
... | let mut pos = 0;
loop {
let samples_generated = player.play(&mut buffer[pos..pos + CHUNK_SIZE]);
if samples_generated == 0 {
break;
}
pos += samples_generated;
buffer.resize(pos + CHUNK_SIZE, 0);
}
buffer.trunca... | {
const CHUNK_SIZE: usize = 16 * 64000;
const SAMPLE_RATE: usize = 44100;
const CHANNEL_COUNT: usize = 2;
const BITS_PER_SAMPLE: usize = 16;
println!("Parsing vtx file...");
let input_file = File::open(self.input)?;
let vtx = Vtx::load(input_file)?;
prin... | identifier_body |
example.rs | const SMALL: &'static [&'static str] = &["zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "se... | (n: u64) -> String {
if n < 20 {
SMALL[n as usize].to_string()
} else if n < 100 {
let small = n % 10;
let mut out = String::from(TENS[n as usize / 10]);
if small > 0 {
out.push('-');
out.push_str(SMALL[small as usize]);
}
out
} else if... | encode | identifier_name |
example.rs | const SMALL: &'static [&'static str] = &["zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "se... | out.push('-');
out.push_str(SMALL[small as usize]);
}
out
} else if n < 1000 {
let mut out = String::from(SMALL[n as usize / 100]);
out.push_str(" hundred");
let ones = n % 100;
if ones > 0 {
out.push(' ');
out.push_str(... | SMALL[n as usize].to_string()
} else if n < 100 {
let small = n % 10;
let mut out = String::from(TENS[n as usize / 10]);
if small > 0 { | random_line_split |
example.rs | const SMALL: &'static [&'static str] = &["zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "se... | }
}
out
}
}
| {
let mut sets: Vec<u64> = Vec::new();
let mut val = n;
while val >= 1 {
sets.push(val % 1000);
val /= 1000;
}
let mut out = String::new();
while let Some(modu) = sets.pop() {
let len = sets.len();
if modu == 0 {
... | conditional_block |
example.rs | const SMALL: &'static [&'static str] = &["zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "se... | } else {
let mut sets: Vec<u64> = Vec::new();
let mut val = n;
while val >= 1 {
sets.push(val % 1000);
val /= 1000;
}
let mut out = String::new();
while let Some(modu) = sets.pop() {
let len = sets.len();
if modu == 0 {
... | {
if n < 20 {
SMALL[n as usize].to_string()
} else if n < 100 {
let small = n % 10;
let mut out = String::from(TENS[n as usize / 10]);
if small > 0 {
out.push('-');
out.push_str(SMALL[small as usize]);
}
out
} else if n < 1000 {
... | identifier_body |
extern-crosscrate.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 ... | (n: uint) -> uint {
unsafe {
debug!("n = %?", n);
externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
}
}
pub fn main() {
let result = fact(10u);
debug!("result = %?", result);
assert!(result == 3628800u);
}
| fact | identifier_name |
extern-crosscrate.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 result = fact(10u);
debug!("result = %?", result);
assert!(result == 3628800u);
} | identifier_body | |
extern-crosscrate.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() {
let result = fact(10u);
debug!("result = %?", result);
assert!(result == 3628800u);
} | externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
} | random_line_split |
index.rs | /// Index into a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) enum Index {
/// Index starting from the beginning of the vector, where `Forward(0)`
/// is the first element
Forward(usize),
/// Index starting from the end of the vector, where `Backward(0)` is the
/// last ele... |
}
| {
if input < 0 {
Index::Backward((input.abs() as usize) - 1)
} else {
Index::Forward(input.abs() as usize)
}
} | identifier_body |
index.rs | /// Index into a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) enum Index {
/// Index starting from the beginning of the vector, where `Forward(0)`
/// is the first element
Forward(usize),
/// Index starting from the end of the vector, where `Backward(0)` is the
/// last ele... | }
/// Construct an index using the following convetions:
/// - A positive value `n` represents `Forward(n)`
/// - A negative value `-n` reprents `Backwards(n - 1)` such that:
/// ```ignore,rust
/// assert_eq!(Index::new(-1), Index::Backward(0))
/// ```
pub(crate) fn new(input: isize) ->... | } | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.