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 |
|---|---|---|---|---|
text.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/. */
//! Text layout.
use layout::box::{RenderBox, RenderBoxBase, TextRenderBox, UnscannedTextRenderBoxClass};
use gf... | range.length(),
run.text);
let new_text_data = TextBoxData::new(run, range);
let metrics = run.metrics_for_range(&range);
base.position.size = metrics.bounding_box.size;
TextRenderBox {
base: base,
text_data: new_text_data,
}
}
pub trait UnscannedMethods {
... | assert!(range.length() > 0);
debug!("Creating textbox with span: (strlen=%u, off=%u, len=%u) of textrun: %s",
run.char_len(),
range.begin(), | random_line_split |
text.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/. */
//! Text layout.
use layout::box::{RenderBox, RenderBoxBase, TextRenderBox, UnscannedTextRenderBoxClass};
use gf... | (&self) -> ~str {
match *self {
UnscannedTextRenderBoxClass(text_box) => copy text_box.text,
_ => fail!(~"unsupported operation: box.raw_text() on non-unscanned text box."),
}
}
}
| raw_text | identifier_name |
body.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 dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::error::{Error, Fallible... | (root: &GlobalScope,
bytes: Vec<u8>,
mime: &[u8]) -> Fallible<FetchedData> {
let mime_string = if let Ok(s) = String::from_utf8(mime.to_vec()) {
s
} else {
"".to_string()
};
let blob = Blob::new(root, BlobImpl::new_from_bytes(bytes), ... | run_blob_data_algorithm | identifier_name |
body.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 dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::error::{Error, Fallible... | #[allow(unrooted_must_root)]
pub fn consume_body_with_promise<T: BodyOperations + Reflectable>(object: &T,
body_type: BodyType,
promise: &Promise) {
// Step 5
let body = match obje... | }
// https://fetch.spec.whatwg.org/#concept-body-consume-body | random_line_split |
body.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 dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::error::{Error, Fallible... | _ => return Err(Error::Type("Inappropriate MIME-type for Body".to_string())),
}
}
pub trait BodyOperations {
fn get_body_used(&self) -> bool;
fn set_body_promise(&self, p: &Rc<Promise>, body_type: BodyType);
/// Returns `Some(_)` if the body is complete, `None` if there is more to
/// come... | {
let mime_str = if let Ok(s) = str::from_utf8(mime) {
s
} else {
""
};
let mime: Mime = try!(mime_str.parse().map_err(
|_| Error::Type("Inappropriate MIME-type for Body".to_string())));
match mime {
// TODO
// ... Parser for Mime(TopLevel::Multipart, SubLevel... | identifier_body |
mod.rs | use jsonwebtoken::Header;
static CERT_CHAIN: [&str; 3] = include!("cert_chain.json");
#[test]
fn x5c_der_empty_chain() {
let header = Header { x5c: None,..Default::default() };
assert_eq!(header.x5c_der().unwrap(), None);
let header = Header { x5c: Some(Vec::new()),..Default::default() };
assert_eq!(... | () {
let der_chain: Vec<Vec<u8>> =
CERT_CHAIN.iter().map(base64::decode).collect::<Result<_, _>>().unwrap();
let x5c = Some(CERT_CHAIN.iter().map(ToString::to_string).collect());
let header = Header { x5c,..Default::default() };
assert_eq!(header.x5c_der().unwrap(), Some(der_chain));
}
#[test... | x5c_der_valid_chain | identifier_name |
mod.rs | use jsonwebtoken::Header;
static CERT_CHAIN: [&str; 3] = include!("cert_chain.json");
#[test]
fn x5c_der_empty_chain() {
let header = Header { x5c: None,..Default::default() }; | let header = Header { x5c: Some(Vec::new()),..Default::default() };
assert_eq!(header.x5c_der().unwrap(), Some(Vec::new()));
}
#[test]
fn x5c_der_valid_chain() {
let der_chain: Vec<Vec<u8>> =
CERT_CHAIN.iter().map(base64::decode).collect::<Result<_, _>>().unwrap();
let x5c = Some(CERT_CHAIN.it... | assert_eq!(header.x5c_der().unwrap(), None);
| random_line_split |
mod.rs | use jsonwebtoken::Header;
static CERT_CHAIN: [&str; 3] = include!("cert_chain.json");
#[test]
fn x5c_der_empty_chain() |
#[test]
fn x5c_der_valid_chain() {
let der_chain: Vec<Vec<u8>> =
CERT_CHAIN.iter().map(base64::decode).collect::<Result<_, _>>().unwrap();
let x5c = Some(CERT_CHAIN.iter().map(ToString::to_string).collect());
let header = Header { x5c,..Default::default() };
assert_eq!(header.x5c_der().unwra... | {
let header = Header { x5c: None, ..Default::default() };
assert_eq!(header.x5c_der().unwrap(), None);
let header = Header { x5c: Some(Vec::new()), ..Default::default() };
assert_eq!(header.x5c_der().unwrap(), Some(Vec::new()));
} | identifier_body |
controller.rs | use std::collections::HashMap;
use std::rc::Rc;
use rustc_serialize::{Decodable, Decoder};
use animation::AnimationClip;
use transform::{Transform, FromTransform};
use blend_tree::{BlendTreeNode, BlendTreeNodeDef, ClipId};
use skeleton::Skeleton;
const MAX_JOINTS: usize = 64;
/// A state that an AnimationController... |
/// Checks if controller should transition to a different state, or if currently
/// in a transition, checks if the transition is complete
fn update_state(&mut self, ext_dt: f64) {
match self.transition.clone() {
Some((ref start_time, ref transition)) => {
// If transit... | {
self.local_clock += delta_time * self.playback_speed;
} | identifier_body |
controller.rs | use std::collections::HashMap;
use std::rc::Rc;
use rustc_serialize::{Decodable, Decoder};
use animation::AnimationClip;
use transform::{Transform, FromTransform};
use blend_tree::{BlendTreeNode, BlendTreeNodeDef, ClipId};
use skeleton::Skeleton;
const MAX_JOINTS: usize = 64;
/// A state that an AnimationController... | })
}));
Ok(AnimationStateDef {
name: name,
blend_tree: blend_tree,
transitions: transitions,
})
})
}
}
/// A runtime representation of an Animation State Machine, consisting of one or more
/// AnimationSta... | Ok(transitions) | random_line_split |
controller.rs | use std::collections::HashMap;
use std::rc::Rc;
use rustc_serialize::{Decodable, Decoder};
use animation::AnimationClip;
use transform::{Transform, FromTransform};
use blend_tree::{BlendTreeNode, BlendTreeNodeDef, ClipId};
use skeleton::Skeleton;
const MAX_JOINTS: usize = 64;
/// A state that an AnimationController... | (&self, parameters: &HashMap<String, f32>) -> bool {
match self.operator {
Operator::LessThan => parameters[&self.parameter[..]] < self.value,
Operator::GreaterThan => parameters[&self.parameter[..]] > self.value,
Operator::LessThanEqual => parameters[&self.parameter[..]] <= ... | is_true | identifier_name |
plist_extractor.rs | use memmem::{Searcher, TwoWaySearcher};
const PLIST_PREFIX: &[u8] = b"<?xml version=";
const PLIST_SUFFIX: &[u8] = b"</plist>";
/// Attempts to find a plist content in a `data` and return it as a slice.
///
/// Since mobileprovision files contain "garbage" at the start and the end you need to extract
/// a plist cont... |
}
None
}
#[cfg(test)]
mod tests {
use super::*;
use expectest::expect;
use expectest::prelude::*;
#[test]
fn test_find_plist() {
let data: &[u8] = b"<?xml version=</plist>";
expect!(find(&data)).to(be_some().value(data));
let data: &[u8] = b" <?xml version=abcd... | {
return Some(&data[start_i..end_i]);
} | conditional_block |
plist_extractor.rs | use memmem::{Searcher, TwoWaySearcher};
const PLIST_PREFIX: &[u8] = b"<?xml version=";
const PLIST_SUFFIX: &[u8] = b"</plist>";
/// Attempts to find a plist content in a `data` and return it as a slice.
///
/// Since mobileprovision files contain "garbage" at the start and the end you need to extract
/// a plist cont... | () {
let data: &[u8] = b"<?xml version=</plist>";
expect!(find(&data)).to(be_some().value(data));
let data: &[u8] = b" <?xml version=abcd</plist> ";
expect!(find(&data)).to(be_some().value(b"<?xml version=abcd</plist>"));
}
}
| test_find_plist | identifier_name |
plist_extractor.rs | use memmem::{Searcher, TwoWaySearcher};
const PLIST_PREFIX: &[u8] = b"<?xml version=";
const PLIST_SUFFIX: &[u8] = b"</plist>";
/// Attempts to find a plist content in a `data` and return it as a slice.
///
/// Since mobileprovision files contain "garbage" at the start and the end you need to extract
/// a plist cont... | return Some(&data[start_i..end_i]);
}
}
None
}
#[cfg(test)]
mod tests {
use super::*;
use expectest::expect;
use expectest::prelude::*;
#[test]
fn test_find_plist() {
let data: &[u8] = b"<?xml version=</plist>";
expect!(find(&data)).to(be_some().value(d... |
if let (Some(start_i), Some(end_i)) = (start_i, end_i) {
if end_i <= data.len() { | random_line_split |
plist_extractor.rs | use memmem::{Searcher, TwoWaySearcher};
const PLIST_PREFIX: &[u8] = b"<?xml version=";
const PLIST_SUFFIX: &[u8] = b"</plist>";
/// Attempts to find a plist content in a `data` and return it as a slice.
///
/// Since mobileprovision files contain "garbage" at the start and the end you need to extract
/// a plist cont... |
#[cfg(test)]
mod tests {
use super::*;
use expectest::expect;
use expectest::prelude::*;
#[test]
fn test_find_plist() {
let data: &[u8] = b"<?xml version=</plist>";
expect!(find(&data)).to(be_some().value(data));
let data: &[u8] = b" <?xml version=abcd</plist> ";
... | {
let prefix_searcher = TwoWaySearcher::new(PLIST_PREFIX);
let suffix_searcher = TwoWaySearcher::new(PLIST_SUFFIX);
let start_i = prefix_searcher.search_in(data);
let end_i = suffix_searcher
.search_in(data)
.map(|i| i + PLIST_SUFFIX.len());
if let (Some(start_i), Some(end_i)) = (st... | identifier_body |
rand.rs | use crate::io;
use crate::mem;
use crate::sys::c;
#[cfg(not(target_vendor = "uwp"))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut v = (0, 0);
let ret =
unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
if ret == 0 {
panic!("couldn't generate ... | #[cfg(target_vendor = "uwp")]
pub fn hashmap_random_keys() -> (u64, u64) {
use crate::ptr;
let mut v = (0, 0);
let ret = unsafe {
c::BCryptGenRandom(
ptr::null_mut(),
&mut v as *mut _ as *mut u8,
mem::size_of_val(&v) as c::ULONG,
c::BCRYPT_USE_SYSTEM_... | v
}
| random_line_split |
rand.rs | use crate::io;
use crate::mem;
use crate::sys::c;
#[cfg(not(target_vendor = "uwp"))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut v = (0, 0);
let ret =
unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
if ret == 0 {
panic!("couldn't generate ... |
return v;
}
| {
panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
} | conditional_block |
rand.rs | use crate::io;
use crate::mem;
use crate::sys::c;
#[cfg(not(target_vendor = "uwp"))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut v = (0, 0);
let ret =
unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
if ret == 0 {
panic!("couldn't generate ... | {
use crate::ptr;
let mut v = (0, 0);
let ret = unsafe {
c::BCryptGenRandom(
ptr::null_mut(),
&mut v as *mut _ as *mut u8,
mem::size_of_val(&v) as c::ULONG,
c::BCRYPT_USE_SYSTEM_PREFERRED_RNG,
)
};
if ret != 0 {
panic!("couldn'... | identifier_body | |
rand.rs | use crate::io;
use crate::mem;
use crate::sys::c;
#[cfg(not(target_vendor = "uwp"))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut v = (0, 0);
let ret =
unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
if ret == 0 {
panic!("couldn't generate ... | () -> (u64, u64) {
use crate::ptr;
let mut v = (0, 0);
let ret = unsafe {
c::BCryptGenRandom(
ptr::null_mut(),
&mut v as *mut _ as *mut u8,
mem::size_of_val(&v) as c::ULONG,
c::BCRYPT_USE_SYSTEM_PREFERRED_RNG,
)
};
if ret!= 0 {
... | hashmap_random_keys | identifier_name |
quartic_depressed.rs | // Copyright (c) 2015, Mikhail Vorotilov
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of condit... | () {
assert_eq!(find_roots_quartic_depressed(0f32, 0f32, 0f32), Roots::One([0f32]));
assert_eq!(find_roots_quartic_depressed(1f32, 1f32, 1f32), Roots::No([]));
// Thanks WolframAlpha for the test data
match find_roots_quartic_depressed(1f64, 1f64, -1f64) {
Roots::Two(x) => {... | test_find_roots_quartic_depressed | identifier_name |
quartic_depressed.rs | // Copyright (c) 2015, Mikhail Vorotilov
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of condit... | let resolvent_roots = super::cubic_normalized::find_roots_cubic_normalized(b2, b1, b0);
let y = resolvent_roots.as_ref().iter().last().unwrap();
let _a2_plus_2y = a2 + _2 * *y;
if _a2_plus_2y > F::zero() {
let sqrt_a2_plus_2y = _a2_plus_2y.sqrt();
let q0a = a2 + ... | {
// Handle non-standard cases
if a1 == F::zero() {
// a1 = 0; x^4 + a2*x^2 + a0 = 0; solve biquadratic equation
super::biquadratic::find_roots_biquadratic(F::one(), a2, a0)
} else if a0 == F::zero() {
// a0 = 0; x^4 + a2*x^2 + a1*x = 0; reduce to normalized cubic and add zero root
... | identifier_body |
quartic_depressed.rs | // Copyright (c) 2015, Mikhail Vorotilov
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of condit... | fn test_find_roots_quartic_depressed() {
assert_eq!(find_roots_quartic_depressed(0f32, 0f32, 0f32), Roots::One([0f32]));
assert_eq!(find_roots_quartic_depressed(1f32, 1f32, 1f32), Roots::No([]));
// Thanks WolframAlpha for the test data
match find_roots_quartic_depressed(1f64, 1f64,... |
#[test] | random_line_split |
quartic_depressed.rs | // Copyright (c) 2015, Mikhail Vorotilov
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of condit... | else if a0 == F::zero() {
// a0 = 0; x^4 + a2*x^2 + a1*x = 0; reduce to normalized cubic and add zero root
super::cubic_normalized::find_roots_cubic_normalized(F::zero(), a2, a1).add_new_root(F::zero())
} else {
let _2 = F::from(2i16);
let _5 = F::from(5i16);
// Solve the a... | {
// a1 = 0; x^4 + a2*x^2 + a0 = 0; solve biquadratic equation
super::biquadratic::find_roots_biquadratic(F::one(), a2, a0)
} | conditional_block |
issue-17718.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 ... | () {}
| foo | identifier_name |
issue-17718.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 | |
issue-17718.rs | // 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 accordin... | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | random_line_split | |
lib.rs | extern crate byteorder;
extern crate encoding;
#[macro_use] extern crate log;
use std::io::{Read, Write};
use std::io;
/// PC crypto. Used by patch server on BB as well. The Dreamcast and
/// PC versions share this crypto.
pub mod pc;
/// Blue Burst-specific crypto. A lot more complex than PC and GC.
pub mod bb;
//... | (&mut self, buf: &[u8]) -> io::Result<usize> {
let mut int_buf = vec![0u8; buf.len()];
// encrypt into int buffer
if let Err(e) = self.e.encrypt(buf, &mut int_buf[..]) {
return Err(io::Error::new(io::ErrorKind::Other, e))
}
try!(self.w.write_all(&int_buf[..]));
... | write | identifier_name |
lib.rs | extern crate byteorder;
extern crate encoding;
#[macro_use] extern crate log;
use std::io::{Read, Write};
use std::io;
/// PC crypto. Used by patch server on BB as well. The Dreamcast and
/// PC versions share this crypto.
pub mod pc;
/// Blue Burst-specific crypto. A lot more complex than PC and GC.
pub mod bb;
//... |
try!(self.w.write_all(&int_buf[..]));
Ok(buf.len())
}
fn flush(&mut self) -> io::Result<()> {
self.w.flush()
}
}
| {
return Err(io::Error::new(io::ErrorKind::Other, e))
} | conditional_block |
lib.rs | extern crate byteorder;
extern crate encoding;
#[macro_use] extern crate log;
use std::io::{Read, Write};
use std::io;
/// PC crypto. Used by patch server on BB as well. The Dreamcast and
/// PC versions share this crypto.
pub mod pc;
/// Blue Burst-specific crypto. A lot more complex than PC and GC.
pub mod bb;
//... | }
}
pub struct DecryptReader<R: Read, D: Decryptor> {
r: R,
d: D
}
impl<R: Read, D: Decryptor> DecryptReader<R, D> {
pub fn new(read: R, decrypt: D) -> Self {
DecryptReader {
r: read,
d: decrypt
}
}
pub fn into_inner(self) -> R {
self.r
}
}
... | fn decrypt(&mut self, input: &[u8], output: &mut [u8]) -> Result<(), String>;
fn decrypt_in_place(&mut self, buf: &mut [u8]) -> Result<(), String> {
let temp = buf.to_vec();
self.decrypt(&temp, buf) | random_line_split |
rpn.rs | //! Uses RPN expression
extern crate rand;
fn main() {
use rand::Rng;
use std::io::{self, Write};
let mut rng = rand::thread_rng();
let stdin = io::stdin();
let mut stdout = io::stdout();
// generating 4 numbers
let choices: Vec<u32> = (0..4).map(|_| rng.gen_range(1, 10)).collect();
... |
#[test]
fn wrong_numbers_in_input() {
assert_eq!(
check_input("4 5 + 6 2 * -", &v1),
Err("Cannot use 5".to_string())
);
}
#[test]
fn invalid_chars_in_input() {
assert_eq!(
check_input("4 ) + _ 2 * -", &v1),
Err("Invalid input... | {
assert_eq!(
check_input("4 3 * 2 6 + -", &v1),
Err("Wrong answer. Result: 4".to_string())
);
} | identifier_body |
rpn.rs | //! Uses RPN expression
extern crate rand;
fn main() {
use rand::Rng;
use std::io::{self, Write};
let mut rng = rand::thread_rng();
let stdin = io::stdin();
let mut stdout = io::stdout();
// generating 4 numbers
let choices: Vec<u32> = (0..4).map(|_| rng.gen_range(1, 10)).collect();
... | stdin.read_line(&mut buffer).expect("Failed to read line!");
match check_input(&buffer[..], &choices[..]) {
Ok(()) => {
println!("Good job!");
break;
}
Err(e) => println!("{}", e),
}
print!("Try again? (y/n): ");
... | random_line_split | |
rpn.rs | //! Uses RPN expression
extern crate rand;
fn main() {
use rand::Rng;
use std::io::{self, Write};
let mut rng = rand::thread_rng();
let stdin = io::stdin();
let mut stdout = io::stdout();
// generating 4 numbers
let choices: Vec<u32> = (0..4).map(|_| rng.gen_range(1, 10)).collect();
... |
match ans {
Some(x) if x == 24 => Ok(()),
Some(x) => Err(format!("Wrong answer. Result: {}", x)),
None => Err("Error encountered!".to_string()),
}
}
fn evaluate(a: u32, b: u32, op: &str) -> u32 {
match op {
"+" => a + b,
"-" => a - b,
"*" => a * b,
"... | {
return Err("Not a valid RPN expression!".to_string());
} | conditional_block |
rpn.rs | //! Uses RPN expression
extern crate rand;
fn main() {
use rand::Rng;
use std::io::{self, Write};
let mut rng = rand::thread_rng();
let stdin = io::stdin();
let mut stdout = io::stdout();
// generating 4 numbers
let choices: Vec<u32> = (0..4).map(|_| rng.gen_range(1, 10)).collect();
... | (expr: &str, choices: &[u32]) -> Result<(), String> {
let mut stack: Vec<u32> = Vec::new();
for token in expr.split_whitespace() {
if is_operator(token) {
let (a, b) = (stack.pop(), stack.pop());
match (a, b) {
(Some(x), Some(y)) => stack.push(evaluate(y, x, token... | check_input | identifier_name |
lib.rs | where `t! r`
//! is the protocol "send something of type `t` then proceed with
//! protocol `r`", the protocol `t? r` is "receive something of type `t` then proceed
//! with protocol `r`, and `eps` is a special marker indicating the end of a
//! communication session.
//!
//! Our session type library allows the user t... | else {
Ok(Right(self.cast()))
}
} else {
Err(self)
}
}
}
}
impl<E, P> Chan<E, Rec<P>> {
/// Enter a recursive environment, putting the current environment on the
/// top of the environment stack.
#[must_use]
pub fn... | {
Ok(Left(self.cast()))
} | conditional_block |
lib.rs | )` where `t! r`
//! is the protocol "send something of type `t` then proceed with
//! protocol `r`", the protocol `t? r` is "receive something of type `t` then proceed
//! with protocol `r`, and `eps` is a special marker indicating the end of a
//! communication session.
//!
//! Our session type library allows the user... | /// protocol `P`
#[must_use]
pub fn send(self, v: A) -> Chan<E, P> {
unsafe {
write_chan(&self, v);
self.cast()
}
}
}
impl<E, P, A: marker::Send +'static> Chan<E, Recv<A, P>> {
/// Receives a value of type `A` from the channel. Returns a tuple
/// contain... | }
}
impl<E, P, A: marker::Send + 'static> Chan<E, Send<A, P>> {
/// Send a value of type `A` over the channel. Returns a channel with | random_line_split |
lib.rs | where `t! r`
//! is the protocol "send something of type `t` then proceed with
//! protocol `r`", the protocol `t? r` is "receive something of type `t` then proceed
//! with protocol `r`, and `eps` is a special marker indicating the end of a
//! communication session.
//!
//! Our session type library allows the user t... | <'c> {
receivers: Vec<&'c Receiver<*mut u8>>,
}
impl<'c> ChanSelect<'c> {
pub fn new() -> ChanSelect<'c> {
ChanSelect {
receivers: Vec::new(),
}
}
/// Add a channel whose next step is `Recv`
///
/// Once a channel has been added it cannot be interacted with as long ... | ChanSelect | identifier_name |
foreach-nested.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 a: ~[int] = ~[-1, -1, -1, -1];
let mut p: int = 0;
do two |i| {
do two |j| { a[p] = 10 * i + j; p += 1; }
}
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
assert_eq!(a[2], 10);
assert_eq!(a[3], 11);
} | identifier_body | |
foreach-nested.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 mut a: ~[int] = ~[-1, -1, -1, -1];
let mut p: int = 0;
do two |i| {
do two |j| { a[p] = 10 * i + j; p += 1; }
}
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
assert_eq!(a[2], 10);
assert_eq!(a[3], 11);
} |
// -*- rust -*-
fn two(it: &fn(int)) { it(0); it(1); } | random_line_split |
foreach-nested.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 a: ~[int] = ~[-1, -1, -1, -1];
let mut p: int = 0;
do two |i| {
do two |j| { a[p] = 10 * i + j; p += 1; }
}
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
assert_eq!(a[2], 10);
assert_eq!(a[3], 11);
}
| main | identifier_name |
result.rs | use std::num;
use std::io;
use std::result::Result;
use rusqlite::SqliteError;
use std::convert::From;
use db;
use git2;
use url;
use rs_es;
pub type RepoResult<T> = Result<T, RepoError>;
#[derive(Debug)]
pub enum RepoError {
InvalidArgs(String),
EnumParseError(String),
DbError(db::DbError),
SqlError(... | (err: io::Error) -> RepoError {
RepoError::IoError(err)
}
}
| from | identifier_name |
result.rs | use std::num;
use std::io;
use std::result::Result;
use rusqlite::SqliteError;
use std::convert::From;
use db;
use git2;
use url;
use rs_es;
pub type RepoResult<T> = Result<T, RepoError>;
#[derive(Debug)]
pub enum RepoError {
InvalidArgs(String),
EnumParseError(String),
DbError(db::DbError),
SqlError(... |
}
impl From<url::ParseError> for RepoError {
fn from(err: url::ParseError) -> RepoError {
RepoError::UrlParseError(err)
}
}
impl From<rs_es::error::EsError> for RepoError {
fn from(err: rs_es::error::EsError) -> RepoError {
RepoError::ElasticSearchError(err)
}
}
impl From<num::ParseI... | {
RepoError::GitError(err)
} | identifier_body |
result.rs | use std::num;
use std::io;
use std::result::Result;
use rusqlite::SqliteError;
use std::convert::From;
use db;
use git2;
use url;
use rs_es;
pub type RepoResult<T> = Result<T, RepoError>;
#[derive(Debug)]
pub enum RepoError {
InvalidArgs(String),
EnumParseError(String),
DbError(db::DbError),
SqlError(... | fn from(err: io::Error) -> RepoError {
RepoError::IoError(err)
}
} | RepoError::ParseIntError(err)
}
}
impl From<io::Error> for RepoError { | random_line_split |
test.rs |
use std::time::{Instant, Duration};
use scheduler::{oneshot_ms, periodic_ms};
struct ElapsedChecker {
start: Instant
}
impl ElapsedChecker {
fn new() -> ElapsedChecker {
ElapsedChecker {
start: Instant::now()
}
}
fn check(&self, expected_ms: u64) {
let actual_ela... | () {
let checker = ElapsedChecker::new();
let p = periodic_ms(200);
for i in 1..10 {
p.recv().unwrap();
checker.check(i*200);
}
}
| simple_periodic | identifier_name |
test.rs | use std::time::{Instant, Duration};
use scheduler::{oneshot_ms, periodic_ms};
struct ElapsedChecker {
start: Instant
}
impl ElapsedChecker {
fn new() -> ElapsedChecker {
ElapsedChecker {
start: Instant::now()
}
}
fn check(&self, expected_ms: u64) {
let actual_elap... | assert!(actual_elapsed+Duration::from_millis(100) > expected, "Elapsed too soon: {:?} instead of {:?}", actual_elapsed, expected);
}
}
#[test]
fn simple_wait() {
let checker = ElapsedChecker::new();
let timer = oneshot_ms(1400);
timer.recv().unwrap();
checker.check(1400);
}
#[test]
fn seve... | assert!(actual_elapsed > Duration::from_millis(100), "Less than 100ms elapsed");
assert!(actual_elapsed-Duration::from_millis(100) < expected, "Elapsed too late: {:?} instead of {:?}", actual_elapsed, expected); | random_line_split |
test.rs |
use std::time::{Instant, Duration};
use scheduler::{oneshot_ms, periodic_ms};
struct ElapsedChecker {
start: Instant
}
impl ElapsedChecker {
fn new() -> ElapsedChecker {
ElapsedChecker {
start: Instant::now()
}
}
fn check(&self, expected_ms: u64) {
let actual_ela... |
#[test]
fn several_concurrent_waits_misordered() {
let checker = ElapsedChecker::new();
let medium = oneshot_ms(1400);
let short = oneshot_ms(300);
let long = oneshot_ms(2000);
// We wait for the last timer before we check the others,
// so they should all recv immediately after the first one... | {
let checker = ElapsedChecker::new();
let medium = oneshot_ms(1400);
let short = oneshot_ms(300);
let long = oneshot_ms(2000);
short.recv().unwrap();
checker.check(300);
medium.recv().unwrap();
checker.check(1400);
long.recv().unwrap();
checker.check(2000);
} | identifier_body |
builders.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | // specific language governing permissions and limitations
// under the License.
///! Many builders are available to easily create different types of arrow arrays
extern crate arrow;
use arrow::array::Int32Builder;
fn main() {
// Primitive Arrays
//
// Primitive arrays are arrays of fixed-width primitive... | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the | random_line_split |
builders.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | }
| {
// Primitive Arrays
//
// Primitive arrays are arrays of fixed-width primitive types (bool, u8, u16, u32,
// u64, i8, i16, i32, i64, f32, f64)
// Create a new builder with a capacity of 100
let mut primitive_array_builder = Int32Builder::new(100);
// Append an individual primitive value
... | identifier_body |
builders.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | () {
// Primitive Arrays
//
// Primitive arrays are arrays of fixed-width primitive types (bool, u8, u16, u32,
// u64, i8, i16, i32, i64, f32, f64)
// Create a new builder with a capacity of 100
let mut primitive_array_builder = Int32Builder::new(100);
// Append an individual primitive val... | main | identifier_name |
build.rs | // Copyright 2016 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 ... | () {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let (native, target) = match sanitizer_lib_boilerplate("msan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.defin... | main | identifier_name |
build.rs | // Copyright 2016 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 ... | {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let (native, target) = match sanitizer_lib_boilerplate("msan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.define... | identifier_body | |
build.rs | // Copyright 2016 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 ... | use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;
fn main() {
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
let (native, target) = match sanitizer_lib_boilerplate("msan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
... |
extern crate build_helper;
extern crate cmake;
use std::env; | random_line_split |
numeric-method-autoexport.rs | // xfail-pretty
// 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
//... |
// uints
// num
assert!(15u.add(&6u) == 21u);
assert!(15u8.add(&6u8) == 21u8);
assert!(15u16.add(&6u16) == 21u16);
assert!(15u32.add(&6u32) == 21u32);
assert!(15u64.add(&6u64) == 21u64);
// times
15u.times(|| false);
// floats
// num
assert!(10f.to_int() == 10);
assert!(1... | assert!(15i16.add(&6i16) == 21i16);
assert!(15i32.add(&6i32) == 21i32);
assert!(15i64.add(&6i64) == 21i64); | random_line_split |
numeric-method-autoexport.rs | // xfail-pretty
// 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
//... | // floats
// num
assert!(10f.to_int() == 10);
assert!(10f32.to_int() == 10);
assert!(10f64.to_int() == 10);
}
| {
// ints
// num
assert!(15i.add(&6) == 21);
assert!(15i8.add(&6i8) == 21i8);
assert!(15i16.add(&6i16) == 21i16);
assert!(15i32.add(&6i32) == 21i32);
assert!(15i64.add(&6i64) == 21i64);
// uints
// num
assert!(15u.add(&6u) == 21u);
assert!(15u8.add(&6u8) == 21u8);
assert!(15u16.... | identifier_body |
numeric-method-autoexport.rs | // xfail-pretty
// 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
//... | () {
// ints
// num
assert!(15i.add(&6) == 21);
assert!(15i8.add(&6i8) == 21i8);
assert!(15i16.add(&6i16) == 21i16);
assert!(15i32.add(&6i32) == 21i32);
assert!(15i64.add(&6i64) == 21i64);
// uints
// num
assert!(15u.add(&6u) == 21u);
assert!(15u8.add(&6u8) == 21u8);
assert!(15u... | main | identifier_name |
image_test.rs | extern crate glium;
extern crate glium_graphics;
extern crate graphics;
extern crate image;
extern crate piston;
use glium_graphics::{Flip, Glium2d, GliumWindow, OpenGL, Texture, TextureSettings};
use piston::event_loop::EventLoop;
use piston::input::RenderEvent;
use piston::window::WindowSettings;
fn | () {
let opengl = OpenGL::V3_2;
let (w, h) = (300, 300);
let ref mut window: GliumWindow = WindowSettings::new("glium_graphics: image_test", [w, h])
.exit_on_esc(true)
.graphics_api(opengl)
.build()
.unwrap();
let rust_logo = Texture::from_path(
window,
"asse... | main | identifier_name |
image_test.rs | extern crate glium;
extern crate glium_graphics;
extern crate graphics;
extern crate image;
extern crate piston;
use glium_graphics::{Flip, Glium2d, GliumWindow, OpenGL, Texture, TextureSettings};
use piston::event_loop::EventLoop;
use piston::input::RenderEvent;
use piston::window::WindowSettings;
fn main() {
le... |
}
}
| {
let mut target = window.draw();
g2d.draw(&mut target, args.viewport(), |c, g| {
clear(color::WHITE, g);
rectangle(
[1.0, 0.0, 0.0, 1.0],
[0.0, 0.0, 100.0, 100.0],
c.transform,
g,
... | conditional_block |
image_test.rs | extern crate glium;
extern crate glium_graphics;
extern crate graphics;
extern crate image;
extern crate piston;
use glium_graphics::{Flip, Glium2d, GliumWindow, OpenGL, Texture, TextureSettings};
use piston::event_loop::EventLoop;
use piston::input::RenderEvent;
use piston::window::WindowSettings;
fn main() | use graphics::*;
if let Some(args) = e.render_args() {
let mut target = window.draw();
g2d.draw(&mut target, args.viewport(), |c, g| {
clear(color::WHITE, g);
rectangle(
[1.0, 0.0, 0.0, 1.0],
[0.0, 0.0, 100.... | {
let opengl = OpenGL::V3_2;
let (w, h) = (300, 300);
let ref mut window: GliumWindow = WindowSettings::new("glium_graphics: image_test", [w, h])
.exit_on_esc(true)
.graphics_api(opengl)
.build()
.unwrap();
let rust_logo = Texture::from_path(
window,
"ass... | identifier_body |
image_test.rs | extern crate glium;
extern crate glium_graphics;
extern crate graphics;
extern crate image;
extern crate piston;
use glium_graphics::{Flip, Glium2d, GliumWindow, OpenGL, Texture, TextureSettings};
use piston::event_loop::EventLoop;
use piston::input::RenderEvent;
use piston::window::WindowSettings;
| let ref mut window: GliumWindow = WindowSettings::new("glium_graphics: image_test", [w, h])
.exit_on_esc(true)
.graphics_api(opengl)
.build()
.unwrap();
let rust_logo = Texture::from_path(
window,
"assets/rust.png",
Flip::None,
&TextureSettings::new()... | fn main() {
let opengl = OpenGL::V3_2;
let (w, h) = (300, 300); | random_line_split |
monad.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... | {
assert_eq!(transform(Some(10)), Some("11".to_string()));
assert_eq!(transform(None), None);
assert!((vec!("hi".to_string()))
.bind(|x| vec!(x.clone(), format!("{}!", x)) )
.bind(|x| vec!(x.clone(), format!("{}?", x)) ) ==
vec!("hi".to_string(),
"hi?".to_string(),
... | identifier_body | |
monad.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... | <B>(&self, f: |&A| -> Option<B>) -> Option<B> {
match *self {
Some(ref a) => { f(a) }
None => { None }
}
}
}
fn transform(x: Option<int>) -> Option<String> {
x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str()) )
}
pub fn main() {
assert_eq!(transform(Some(10)), Some... | bind | identifier_name |
monad.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... | vec!("hi".to_string(),
"hi?".to_string(),
"hi!".to_string(),
"hi!?".to_string()));
} | .bind(|x| vec!(x.clone(), format!("{}?", x)) ) == | random_line_split |
lib.rs | pub use self::{animal::*, food::*, world::*};
mod animal;
mod food;
mod world;
use lib_simulation as sim;
use rand::prelude::*;
use serde::Serialize;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Simulation {
rng: ThreadRng,
sim: sim::Simulation,
}
#[wasm_bindgen]
impl Simulation {
#[wasm_bin... | JsValue::from_serde(&world).unwrap()
}
pub fn step(&mut self) -> Option<String> {
self.sim.step(&mut self.rng).map(|stats| stats.to_string())
}
pub fn train(&mut self) -> String {
self.sim.train(&mut self.rng).to_string()
}
} | pub fn world(&self) -> JsValue {
let world = World::from(self.sim.world()); | random_line_split |
lib.rs | pub use self::{animal::*, food::*, world::*};
mod animal;
mod food;
mod world;
use lib_simulation as sim;
use rand::prelude::*;
use serde::Serialize;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Simulation {
rng: ThreadRng,
sim: sim::Simulation,
}
#[wasm_bindgen]
impl Simulation {
#[wasm_bin... | (&self) -> JsValue {
JsValue::from_serde(self.sim.config()).unwrap()
}
pub fn world(&self) -> JsValue {
let world = World::from(self.sim.world());
JsValue::from_serde(&world).unwrap()
}
pub fn step(&mut self) -> Option<String> {
self.sim.step(&mut self.rng).map(|stats| ... | config | identifier_name |
shootout-mandelbrot.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... | fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec<u8>) {
for chunk_init_r in vec_init_r.chunks(8) {
let mut cur_byte = 0xff;
let mut cur_bitmask = 0x80;
for &init_r in chunk_init_r.iter() {
let mut cur_r = init_r;
let mut cur_i = init_i;
for _ i... | random_line_split | |
shootout-mandelbrot.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... | res.push(cur_byte);
}
}
fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
// Ensure w and h are multiples of 8.
let w = (w + 7) / 8 * 8;
let h = w;
let chunk_size = h / 8;
let data: Vec<Future<Vec<u8>>> = range(0u, 8).map(|i| Future::spawn(proc () {
let v... | {
for chunk_init_r in vec_init_r.chunks(8) {
let mut cur_byte = 0xff;
let mut cur_bitmask = 0x80;
for &init_r in chunk_init_r.iter() {
let mut cur_r = init_r;
let mut cur_i = init_i;
for _ in range(0, ITER) {
let r = cur_r;
... | identifier_body |
shootout-mandelbrot.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... | <W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
// Ensure w and h are multiples of 8.
let w = (w + 7) / 8 * 8;
let h = w;
let chunk_size = h / 8;
let data: Vec<Future<Vec<u8>>> = range(0u, 8).map(|i| Future::spawn(proc () {
let vec_init_r = Vec::from_fn(w, |x| 2.0 * (x as f64) / ... | mandelbrot | identifier_name |
shootout-mandelbrot.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... |
}
cur_bitmask >>= 1;
}
res.push(cur_byte);
}
}
fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
// Ensure w and h are multiples of 8.
let w = (w + 7) / 8 * 8;
let h = w;
let chunk_size = h / 8;
let data: Vec<Future<Vec<u8>>> = ran... | {
cur_byte &= !cur_bitmask;
break;
} | conditional_block |
module.rs | use std::collections::{HashMap, HashSet};
use super::{Expression, Call, TreePrinter, TypeDeclaration, Import, ImportName, Symbol, SymbolType, GlobalBinding, Function, ExternalFunction, prefix};
use target::Target;
use compileerror::CompileResult;
pub struct Module
{
pub name: String,
pub globals: HashMap<Strin... | (&self, call: &Call) -> bool {
!self.functions.contains_key(&call.callee.name) &&
!self.externals.contains_key(&call.callee.name)
}
fn get_imported_symbols(&self, target: &Target) -> HashMap<String, Symbol>
{
let mut symbols = HashMap::new();
for func in self.functions.values(... | is_imported_call | identifier_name |
module.rs | use std::collections::{HashMap, HashSet};
use super::{Expression, Call, TreePrinter, TypeDeclaration, Import, ImportName, Symbol, SymbolType, GlobalBinding, Function, ExternalFunction, prefix};
use target::Target;
use compileerror::CompileResult;
pub struct Module
{
pub name: String,
pub globals: HashMap<Strin... | let symbol = Symbol::new(&call.callee.name, &typ, false, &call.span, SymbolType::External);
symbols.insert(call.callee.name.clone(), symbol);
}
_ => (),
}
Ok(())
};
let _ = f... | match *e {
Expression::Call(ref call) if self.is_imported_call(call) => {
let typ = call.callee_type(target.int_size); | random_line_split |
module.rs | use std::collections::{HashMap, HashSet};
use super::{Expression, Call, TreePrinter, TypeDeclaration, Import, ImportName, Symbol, SymbolType, GlobalBinding, Function, ExternalFunction, prefix};
use target::Target;
use compileerror::CompileResult;
pub struct Module
{
pub name: String,
pub globals: HashMap<Strin... |
fn is_imported_call(&self, call: &Call) -> bool {
!self.functions.contains_key(&call.callee.name) &&
!self.externals.contains_key(&call.callee.name)
}
fn get_imported_symbols(&self, target: &Target) -> HashMap<String, Symbol>
{
let mut symbols = HashMap::new();
for func ... | {
Module{
name: name.into(),
globals: HashMap::new(),
functions: HashMap::new(),
externals: HashMap::new(),
types: HashMap::new(),
import_names: HashSet::new(),
type_checked: false,
}
} | identifier_body |
audioclient.rs | // 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 copied, modified, or distributed
// except according ... | pub const AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: HRESULT = AUDCLNT_ERR!(0x00e);
pub const AUDCLNT_E_ENDPOINT_CREATE_FAILED: HRESULT = AUDCLNT_ERR!(0x00f);
pub const AUDCLNT_E_SERVICE_NOT_RUNNING: HRESULT = AUDCLNT_ERR!(0x010);
pub const AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: HRESULT = AUDCLNT_ERR!(0x011);
pub const AUDCLNT... | pub const AUDCLNT_E_BUFFER_OPERATION_PENDING: HRESULT = AUDCLNT_ERR!(0x00b);
pub const AUDCLNT_E_THREAD_NOT_REGISTERED: HRESULT = AUDCLNT_ERR!(0x00c); | 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 http://mozilla.org/MPL/2.0/. */
use canvas_traits::webgl::webgl_channel;
use canvas_traits::webgl::DOMToTextureCommand;
use canvas_traits::webgl::... | }
}
/// Bridge between the WR frame outputs and WebGL to implement DOMToTexture synchronization.
impl webrender::OutputImageHandler for OutputHandler {
fn lock(
&mut self,
id: webrender_api::PipelineId,
) -> Option<(u32, webrender_api::DeviceIntSize)> {
// Insert a fence in the WR c... | lock_channel: webgl_channel().unwrap(),
sync_objects: Default::default(),
} | 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 http://mozilla.org/MPL/2.0/. */
use canvas_traits::webgl::webgl_channel;
use canvas_traits::webgl::DOMToTextureCommand;
use canvas_traits::webgl::... | {
webrender_gl: Rc<dyn gl::Gl>,
webgl_channel: WebGLSender<WebGLMsg>,
// Used to avoid creating a new channel on each received WebRender request.
lock_channel: (
WebGLSender<(u32, Size2D<i32>, usize)>,
WebGLReceiver<(u32, Size2D<i32>, usize)>,
),
}
impl WebGLExternalImages {
fn... | WebGLExternalImages | 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 http://mozilla.org/MPL/2.0/. */
use canvas_traits::webgl::webgl_channel;
use canvas_traits::webgl::DOMToTextureCommand;
use canvas_traits::webgl::... | else {
None
};
let external =
WebGLExternalImageHandler::new(WebGLExternalImages::new(webrender_gl, channel.clone()));
(
WebGLThreads(channel),
Box::new(external),
output_handler.map(|b| b as Box<_>),
)
}
/// Gets the ... | {
Some(Box::new(OutputHandler::new(
webrender_gl.clone(),
channel.clone(),
)))
} | conditional_block |
choose.rs | //! depends: rand = "0.3"
//! depends: regex = "0.2"
extern crate zaldinar_core;
extern crate regex;
extern crate rand;
use rand::Rng;
use zaldinar_core::client::PluginRegister;
use zaldinar_core::events::CommandEvent;
macro_rules! regex {
($s:expr) => (::regex::Regex::new($s).unwrap())
}
fn choose(event: &Com... | ,
};
let mut rng = rand::thread_rng();
event.client.send_message(event.channel(), format!("{}", rng.gen_range(0, max) + 1));
}
pub fn register(register: &mut PluginRegister) {
register.register_command("choose", choose);
register.register_command("coin", coin);
register.register_command("rand",... | {
event.client.send_message(event.channel(),
format!("Invalid number '{}'", event.args[0]));
return;
} | conditional_block |
choose.rs | //! depends: rand = "0.3"
//! depends: regex = "0.2"
extern crate zaldinar_core;
extern crate regex;
extern crate rand;
use rand::Rng;
use zaldinar_core::client::PluginRegister;
use zaldinar_core::events::CommandEvent;
macro_rules! regex {
($s:expr) => (::regex::Regex::new($s).unwrap())
}
fn choose(event: &Com... |
fn coin(event: &CommandEvent) {
let mut rng = rand::thread_rng();
let message = format!("\x01ACTION flips a coin... \x02{}\x02\x01", rng.choose(&["heads",
"tails"]).unwrap());
event.client.send_message(event.channel(), message);
}... | {
let content = event.args.join(" ");
let mut rng = rand::thread_rng();
let split = if content.contains(",") {
regex!(r"\s*,\s*").split(&content).collect::<Vec<&str>>()
} else {
regex!(r"\s+").split(&content).collect::<Vec<&str>>()
};
let message = match rng.choose(&split) {
... | identifier_body |
choose.rs | //! depends: rand = "0.3"
//! depends: regex = "0.2"
extern crate zaldinar_core;
extern crate regex;
extern crate rand;
use rand::Rng;
use zaldinar_core::client::PluginRegister;
use zaldinar_core::events::CommandEvent;
macro_rules! regex {
($s:expr) => (::regex::Regex::new($s).unwrap())
}
fn choose(event: &Com... | (register: &mut PluginRegister) {
register.register_command("choose", choose);
register.register_command("coin", coin);
register.register_command("rand", rand_command);
}
| register | identifier_name |
choose.rs | //! depends: rand = "0.3"
//! depends: regex = "0.2"
extern crate zaldinar_core;
extern crate regex;
extern crate rand;
use rand::Rng;
use zaldinar_core::client::PluginRegister;
use zaldinar_core::events::CommandEvent;
macro_rules! regex {
($s:expr) => (::regex::Regex::new($s).unwrap())
}
fn choose(event: &Com... | event.client.send_message(event.channel(), message);
}
fn coin(event: &CommandEvent) {
let mut rng = rand::thread_rng();
let message = format!("\x01ACTION flips a coin... \x02{}\x02\x01", rng.choose(&["heads",
"tails"]).unwrap());
... | Some(v) => *v,
None => "I don't have anything to choose from.",
}; | random_line_split |
type_of.rs | , RegionEscape, Ty};
use util::ppaux;
use util::ppaux::Repr;
use trans::type_::Type;
use std::num::Int;
use syntax::abi;
use syntax::ast;
// LLVM doesn't like objects that are too big. Issue #17913
fn ensure_array_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
... |
pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
if ty::type_is_bool(t) {
Type::i1(cx)
} else if type_is_immediate(cx, t) && type_of(cx, t).is_aggregate() {
// We want to pass small aggregates as immediate values, but using an aggregate LLVM type
// for ... | {
if ty::type_is_bool(t) {
Type::i1(cx)
} else {
type_of(cx, t)
}
} | identifier_body |
type_of.rs | ::{self, RegionEscape, Ty};
use util::ppaux;
use util::ppaux::Repr;
use trans::type_::Type;
use std::num::Int;
use syntax::abi;
use syntax::ast;
// LLVM doesn't like objects that are too big. Issue #17913
fn ensure_array_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
... | //... then explicit args.
let input_tys = inputs.iter().map(|&arg_ty| type_of_explicit_arg(cx, arg_ty));
atys.extend(input_tys);
Type::func(&atys[], &lloutputtype)
}
// Given a function type and a count of ty params, construct an llvm type
pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx... | random_line_split | |
type_of.rs | (scapegoat) }
}
}
pub fn arg_is_indirect<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
arg_ty: Ty<'tcx>) -> bool {
!type_is_immediate(ccx, arg_ty)
}
pub fn return_uses_outptr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty: Ty<'tcx>) -> bool {
!type_... | type_of_dtor | identifier_name | |
action.rs | use RawFd;
| }
impl Action {
#[inline]
pub fn encode(action: Action) -> u64 {
match action {
Action::Notify(data, fd) => ((fd as u64) << 31) | ((data as u64) << 15),
Action::New(data) => data,
}
}
#[inline]
pub fn decode(data: u64) -> Action {
let arg1 = ((data >> 15) & 0xffff) as usize;
let ... | pub enum Action {
Notify(usize, RawFd),
New(u64), | random_line_split |
action.rs | use RawFd;
pub enum Action {
Notify(usize, RawFd),
New(u64),
}
impl Action {
#[inline]
pub fn | (action: Action) -> u64 {
match action {
Action::Notify(data, fd) => ((fd as u64) << 31) | ((data as u64) << 15),
Action::New(data) => data,
}
}
#[inline]
pub fn decode(data: u64) -> Action {
let arg1 = ((data >> 15) & 0xffff) as usize;
let fd = (data >> 31) as i32;
match data & 0... | encode | identifier_name |
action.rs | use RawFd;
pub enum Action {
Notify(usize, RawFd),
New(u64),
}
impl Action {
#[inline]
pub fn encode(action: Action) -> u64 |
#[inline]
pub fn decode(data: u64) -> Action {
let arg1 = ((data >> 15) & 0xffff) as usize;
let fd = (data >> 31) as i32;
match data & 0x7fff {
0 => Action::Notify(arg1, fd),
_ => Action::New(data),
}
}
}
#[cfg(test)]
mod tests {
use super::Action;
#[test]
fn decode_encode_new... | {
match action {
Action::Notify(data, fd) => ((fd as u64) << 31) | ((data as u64) << 15),
Action::New(data) => data,
}
} | identifier_body |
servoxmlparser.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 dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
use dom::binding... |
let tree_builder = self.sink();
tree_builder.trace_handles(tracer);
tree_builder.sink().trace(trc);
}
} | let tracer = &tracer as &tree_builder::Tracer<Handle=JS<Node>>; | random_line_split |
servoxmlparser.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 dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
use dom::binding... |
pub fn suspend(&self) {
assert!(!self.suspended.get());
self.suspended.set(true);
}
pub fn is_suspended(&self) -> bool {
self.suspended.get()
}
pub fn parse_sync(&self) {
// This parser will continue to parse while there is either pending input or
// the p... | {
assert!(self.suspended.get());
self.suspended.set(false);
self.parse_sync();
} | identifier_body |
servoxmlparser.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 dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
use dom::binding... | (&self) -> &Window {
self.document.window()
}
pub fn resume(&self) {
assert!(self.suspended.get());
self.suspended.set(false);
self.parse_sync();
}
pub fn suspend(&self) {
assert!(!self.suspended.get());
self.suspended.set(true);
}
pub fn is_sus... | window | identifier_name |
servoxmlparser.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 dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
use dom::binding... |
}
if self.last_chunk_received.get() {
self.finish();
}
}
pub fn pending_input(&self) -> &DOMRefCell<Vec<String>> {
&self.pending_input
}
pub fn set_plaintext_state(&self) {
//self.tokenizer.borrow_mut().set_plaintext_state()
}
pub fn end_t... | {
break;
} | conditional_block |
repr-transparent-other-reprs.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 ... |
#[repr(transparent)] //~ ERROR cannot have other repr
#[repr(C)]
struct SeparateAttributes(*mut u8);
fn main() {} | struct TransparentPlusAlign(u8); | random_line_split |
repr-transparent-other-reprs.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 ... | {
ptr: *const u8
}
#[repr(transparent, packed)] //~ ERROR cannot have other repr
struct TransparentPlusPacked(*const u8);
#[repr(transparent, align(2))] //~ ERROR cannot have other repr
struct TransparentPlusAlign(u8);
#[repr(transparent)] //~ ERROR cannot have other repr
#[repr(C)]
struct SeparateAttributes(*m... | TransparentPlusC | identifier_name |
cssnamespacerule.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 dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... | {
cssrule: CSSRule,
#[ignore_heap_size_of = "Arc"]
namespacerule: Arc<RwLock<NamespaceRule>>,
}
impl CSSNamespaceRule {
fn new_inherited(parent: Option<&CSSStyleSheet>, namespacerule: Arc<RwLock<NamespaceRule>>) -> CSSNamespaceRule {
CSSNamespaceRule {
cssrule: CSSRule::new_inherit... | CSSNamespaceRule | identifier_name |
cssnamespacerule.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 dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... |
}
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
fn Prefix(&self) -> DOMString {
self.namespacerule.read().prefix
.as_ref().map(|s| s.to_string().into())
.unwrap_or(DOMString::new())
}
// https://drafts.... | {
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent, namespacerule),
window,
CSSNamespaceRuleBinding::Wrap)
} | identifier_body |
cssnamespacerule.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 dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... | }
}
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
fn Prefix(&self) -> DOMString {
self.namespacerule.read().prefix
.as_ref().map(|s| s.to_string().into())
.unwrap_or(DOMString::new())
}
// https://dr... | reflect_dom_object(box CSSNamespaceRule::new_inherited(parent, namespacerule),
window,
CSSNamespaceRuleBinding::Wrap) | random_line_split |
p22.rs | use std::time::{SystemTime, UNIX_EPOCH};
use rand::{Rng, SeedableRng, weak_rng};
use util::MT19937Rng;
fn epoch_time() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH).unwrap()
.as_secs()
}
#[test]
fn run() {
let mut w_rng = weak_rng();
let mut mt_rng = MT19937Rng::new_unseeded();
... |
}
assert!(recovered_seed.is_some());
assert_eq!(seed, recovered_seed.unwrap());
}
| {
recovered_seed = Some(seed2);
} | conditional_block |
p22.rs | use std::time::{SystemTime, UNIX_EPOCH};
use rand::{Rng, SeedableRng, weak_rng};
use util::MT19937Rng;
fn epoch_time() -> u64 |
#[test]
fn run() {
let mut w_rng = weak_rng();
let mut mt_rng = MT19937Rng::new_unseeded();
let mut t = epoch_time();
//// Oracle
let wait1: u64 = w_rng.gen_range(10, 1000);
t += wait1;
let seed: u32 = (t & 0xFFFFFFFF) as u32;
mt_rng.reseed(seed);
let wait2: u64 = w_rng.gen_ra... | {
SystemTime::now()
.duration_since(UNIX_EPOCH).unwrap()
.as_secs()
} | identifier_body |
p22.rs | use std::time::{SystemTime, UNIX_EPOCH};
use rand::{Rng, SeedableRng, weak_rng};
use util::MT19937Rng;
fn epoch_time() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH).unwrap()
.as_secs()
}
#[test]
fn run() {
let mut w_rng = weak_rng();
let mut mt_rng = MT19937Rng::new_unseeded();
... | let wait1: u64 = w_rng.gen_range(10, 1000);
t += wait1;
let seed: u32 = (t & 0xFFFFFFFF) as u32;
mt_rng.reseed(seed);
let wait2: u64 = w_rng.gen_range(10, 1000);
t += wait2;
let out = mt_rng.next_u32();
// Attacker
// We simply step backward from our current time until a freshly... | random_line_split | |
p22.rs | use std::time::{SystemTime, UNIX_EPOCH};
use rand::{Rng, SeedableRng, weak_rng};
use util::MT19937Rng;
fn | () -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH).unwrap()
.as_secs()
}
#[test]
fn run() {
let mut w_rng = weak_rng();
let mut mt_rng = MT19937Rng::new_unseeded();
let mut t = epoch_time();
//// Oracle
let wait1: u64 = w_rng.gen_range(10, 1000);
t += wait1;
let... | epoch_time | identifier_name |
buffer.rs | /*
gl/src/gl_wrapper/buffer.rs, 2017-07-19
Copyright (c) 2017 Juuso Tuononen
This file is licensed under
Apache License, Version 2.0
or
MIT License
*/
//! Send data to GPU.
use super::gl_raw;
use self::gl_raw::types::*;
use std::mem::size_of;
use std::os::raw::c_void;
use std::ptr;
/// Send static data to GPU... |
/// Set vertex attribute to match buffer data.
///
/// # Arguments
/// * `attribute_index` - Index of vertex attribute.
fn set_vertex_attributes(&mut self, attribute_index: GLuint) {
unsafe {
gl_raw::BindBuffer(gl_raw::ARRAY_BUFFER, self.id);
let stride = (self.att... | {
let mut id: GLuint = 0;
gl_raw::GenBuffers(1, &mut id);
gl_raw::BindBuffer(gl_raw::ARRAY_BUFFER, id);
let size: GLsizeiptr = (size_of::<f32>() * data.len()) as GLsizeiptr;
let data_ptr = data.as_ptr() as *const c_void;
gl_raw::BufferData(gl_raw::ARRAY_BUFFER, size, d... | identifier_body |
buffer.rs | /*
gl/src/gl_wrapper/buffer.rs, 2017-07-19
Copyright (c) 2017 Juuso Tuononen
This file is licensed under
Apache License, Version 2.0
or
MIT License
*/
//! Send data to GPU.
use super::gl_raw;
use self::gl_raw::types::*;
use std::mem::size_of;
use std::os::raw::c_void;
use std::ptr;
/// Send static data to GPU... |
#[cfg(not(feature = "gles"))]
{
let mut buffer;
unsafe {
buffer = VertexBufferStatic::new(data, attribute_component_count);
}
self.bind();
buffer.set_vertex_attributes(attribute_index);
self.vertex_buffers.push(b... | {
panic!("buffer length doesn't match with attribute_component_count");
} | conditional_block |
buffer.rs | /*
gl/src/gl_wrapper/buffer.rs, 2017-07-19
Copyright (c) 2017 Juuso Tuononen
This file is licensed under
Apache License, Version 2.0
or
MIT License
*/
//! Send data to GPU.
use super::gl_raw;
use self::gl_raw::types::*;
use std::mem::size_of;
use std::os::raw::c_void;
use std::ptr;
/// Send static data to GPU... | (&mut self, attribute_index: GLuint) {
unsafe {
gl_raw::BindBuffer(gl_raw::ARRAY_BUFFER, self.id);
let stride = (self.attribute_component_count * size_of::<f32>() as GLint) as GLsizei;
gl_raw::VertexAttribPointer(attribute_index, self.attribute_component_count, gl_raw::FLOAT... | set_vertex_attributes | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.