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 |
|---|---|---|---|---|
owned.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 ... | #[inline]
fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
#[inline]
fn ne(&self, other: &Box<T>) -> bool { *(*self)!= *(*other) }
}
impl<T:Ord> Ord for Box<T> {
#[inline]
fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
#[inline]
fn le(&self, other: &Box<T>) -... | }
// box pointers
impl<T:Eq> Eq for Box<T> { | random_line_split |
tokenizer.rs | use super::Matcher;
use super::{Token, TokenType, TokenPosition};
#[derive(Clone, Debug)]
pub struct Snapshot {
pub pos: TokenPosition,
pub index: usize,
}
impl Snapshot {
pub fn new(index: usize, pos: TokenPosition) -> Snapshot {
Snapshot {
index,
pos,
}
}
}
#... |
Some(&self.items[self.index + n])
}
pub fn read(&mut self) -> Option<&char> {
if self.end() {
return None
}
self.advance(1);
Some(&self.items[self.index - 1])
}
pub fn advance(&mut self, a: usize) {
if self.index + a <= self.items.len() {
... | {
return None
} | conditional_block |
tokenizer.rs | use super::Matcher;
use super::{Token, TokenType, TokenPosition};
#[derive(Clone, Debug)]
pub struct Snapshot {
pub pos: TokenPosition,
pub index: usize,
}
impl Snapshot {
pub fn new(index: usize, pos: TokenPosition) -> Snapshot {
Snapshot {
index,
pos,
}
}
}
#... |
pub fn advance(&mut self, a: usize) {
if self.index + a <= self.items.len() {
for item in &self.items[self.index.. self.index + a] {
match *item {
'\n' => {
self.pos.line += 1;
self.pos.col = 0;
... | {
if self.end() {
return None
}
self.advance(1);
Some(&self.items[self.index - 1])
} | identifier_body |
tokenizer.rs | use super::Matcher;
use super::{Token, TokenType, TokenPosition};
#[derive(Clone, Debug)]
pub struct Snapshot {
pub pos: TokenPosition,
pub index: usize,
}
impl Snapshot {
pub fn new(index: usize, pos: TokenPosition) -> Snapshot {
Snapshot {
index,
pos,
}
}
}
#... | (&mut self) {
self.snapshots.pop();
}
pub fn last_position(&self) -> TokenPosition {
self.peek_snapshot().unwrap().pos
}
pub fn try_match_token(&mut self, matcher: &Matcher) -> Option<Token> {
if self.end() {
return Some(Token::new(TokenType::EOF,
... | commit_snapshot | identifier_name |
tokenizer.rs | use super::Matcher;
use super::{Token, TokenType, TokenPosition};
#[derive(Clone, Debug)]
pub struct Snapshot {
pub pos: TokenPosition,
pub index: usize,
}
impl Snapshot {
pub fn new(index: usize, pos: TokenPosition) -> Snapshot {
Snapshot {
index,
pos,
}
}
}
#... | self.take_snapshot();
match matcher.try_match(self) {
Some(t) => {
self.commit_snapshot();
Some(t)
}
None => {
self.rollback_snapshot();
None
}
}
}
pub fn index(&self) -> &us... | TokenPosition::new(self.index, self.index),
String::new()));
}
| random_line_split |
mod.rs | //! M17n
//!
//! The docs in this module quote the [m17n "Data format of the m17n database"
//! docs][1] a lot.
//!
//! [1]: https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html
use regex::Regex;
use std::{convert::TryFrom, str::FromStr};
mod ser;
pub use ser::ToMim;
/// M17n Input Method, i.e., the content of a ... | /// > `\r`, and `\e` are replaced with tab (code 9), newline (code 10), carriage
/// > return (code 13), and escape (code 27) respectively. Other characters
/// > following a backslash is interpreted as it is. The value of the property
/// > is the symbol having the resulting string as its name.
/// >
/// > For instanc... | ///
/// [Defined](https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html) as:
///
/// > An element that matches the regular expression `[^-0-9(]([^\()]|\.)+`
/// > represents a property whose key is `Msymbol`. In the element, `\t`, `\n`, | random_line_split |
mod.rs | //! M17n
//!
//! The docs in this module quote the [m17n "Data format of the m17n database"
//! docs][1] a lot.
//!
//! [1]: https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html
use regex::Regex;
use std::{convert::TryFrom, str::FromStr};
mod ser;
pub use ser::ToMim;
/// M17n Input Method, i.e., the content of a ... | {
pub name: Symbol,
pub rules: Vec<Rule>,
}
// RULE ::= '(' KEYSEQ MAP-ACTION * ')'
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct Rule {
/// Keys to press to produce mapping
pub keyseq: KeySeq,
/// The mapping describes what to do
///
/// Right now we only support inse... | Map | identifier_name |
mod.rs | //! M17n
//!
//! The docs in this module quote the [m17n "Data format of the m17n database"
//! docs][1] a lot.
//!
//! [1]: https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html
use regex::Regex;
use std::{convert::TryFrom, str::FromStr};
mod ser;
pub use ser::ToMim;
/// M17n Input Method, i.e., the content of a ... |
// hex
if!(input.starts_with("0x") || input.starts_with("0X")) {
return Err(MimConversion::InvalidIntegerHexPrefix { input });
}
match u64::from_str_radix(&input[2..], 16) {
Ok(_) => Ok(Integer(input)),
Err(source) => Err(MimConversion::InvalidIntege... | {
return Ok(Integer(input));
} | conditional_block |
c_vec.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 ... | Some(f) => f()
}
}
}
impl<T> CVec<T> {
/// Create a `CVec` from a raw pointer to a buffer with a given length.
///
/// Fails if the given pointer is null. The returned vector will not attempt
/// to deallocate the vector when dropped.
///
/// # Arguments
///
/// ... | impl<T> Drop for CVec<T> {
fn drop(&mut self) {
match self.dtor.take() {
None => (), | random_line_split |
c_vec.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 cv = malloc(16);
assert!(cv.get_mut(17).is_none());
}
#[test]
fn test_unwrap() {
unsafe {
let cv = CVec::new_with_dtor(1 as *mut int, 0,
proc() { fail!("Don't run this destructor!") });
let p = cv.unwrap();
assert_eq!... | test_overrun_set | identifier_name |
c_vec.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 ... |
}
impl<T> CVec<T> {
/// Create a `CVec` from a raw pointer to a buffer with a given length.
///
/// Fails if the given pointer is null. The returned vector will not attempt
/// to deallocate the vector when dropped.
///
/// # Arguments
///
/// * base - A raw pointer to a buffer
///... | {
match self.dtor.take() {
None => (),
Some(f) => f()
}
} | identifier_body |
cmn.rs | to it
/// are made.
/// The matching `finished()` call will always be made, no matter whether or not the API
/// request was successful. That way, the delegate may easily maintain a clean state
/// between various API calls.
fn begin(&mut self, MethodInfo) {}
/// Called whenever there is an [... |
/// Returns true if we are handling our last part
fn is_last_part(&self) -> bool {
self.raw_parts.len() == 0 && self.current_part.is_some()
}
}
impl<'a> Read for MultiPartReader<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match (self.raw_parts.len(),
... | {
self.raw_parts.len() == 0 && self.current_part.is_none() && self.last_part_boundary.is_none()
} | identifier_body |
cmn.rs | (&mut self) -> io::Result<std::net::SocketAddr> {
Ok("127.0.0.1:1337".parse().unwrap())
}
}
/// A trait specifying functionality to help controlling any request performed by the API.
/// The trait has a conservative default implementation.
///
/// It contains methods to deal with all common issues, as wel... | peer_addr | identifier_name | |
cmn.rs | calls to it
/// are made.
/// The matching `finished()` call will always be made, no matter whether or not the API
/// request was successful. That way, the delegate may easily maintain a clean state
/// between various API calls.
fn begin(&mut self, MethodInfo) {}
/// Called whenever there i... | #[derive(Default)]
pub struct MultiPartReader<'a> {
raw_parts: Vec<(Headers, &'a mut Read)>,
current_part: Option<(Cursor<Vec<u8>>, &'a mut Read)>,
last_part_boundary: Option<Cursor<Vec<u8>>>,
}
impl<'a> MultiPartReader<'a> {
/// Reserve memory for exactly the given amount of parts
pub fn reserve_... |
/// Provides a `Read` interface that converts multiple parts into the protocol
/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387).
/// **Note**: This implementation is just as rich as it needs to be to perform uploads
/// to google APIs, and might not be a fully-featured implementation. | random_line_split |
borrowed-tuple.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | // gdb-command:run
// gdb-command:print *stack_val_ref
// gdbg-check:$1 = {__0 = -14, __1 = -19}
// gdbr-check:$1 = (-14, -19)
// gdb-command:print *ref_to_unnamed
// gdbg-check:$2 = {__0 = -15, __1 = -20}
// gdbr-check:$2 = (-15, -20)
// gdb-command:print *unique_val_ref
// gdbg-check:$3 = {__0 = -17, __1 = -22}
//... | // compile-flags:-g
// === GDB TESTS ===================================================================================
| random_line_split |
borrowed-tuple.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn zzz() {()}
| {
let stack_val: (i16, f32) = (-14, -19f32);
let stack_val_ref: &(i16, f32) = &stack_val;
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
let unique_val: Box<(i16, f32)> = box (-17, -22f32);
let unique_val_ref: &(i16, f32) = &*unique_val;
zzz(); // #break
} | identifier_body |
borrowed-tuple.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {()}
| zzz | identifier_name |
mod.rs | //! Provide helpers for making ioctl system calls
//!
//! Currently supports Linux on all architectures. Other platforms welcome!
//!
//! This library is pretty low-level and messy. `ioctl` is not fun.
//!
//! What is an `ioctl`?
//! ===================
//!
//! The `ioctl` syscall is the grab-bag syscall on POSIX syste... | //! ioctl!(read get_mode_u32 with SPI_IOC_MAGIC, SPI_IOC_NR_MODE; u32);
//! ioctl!(write set_mode_u8 with SPI_IOC_MAGIC, SPI_IOC_NR_MODE; u8);
//! ioctl!(write set_mode_u32 with SPI_IOC_MAGIC, SPI_IOC_NR_MODE32; u32);
//! ioctl!(read get_lsb_first with SPI_IOC_MAGIC, SPI_IOC_NR_LSB_FIRST; u8);
//! ... | //! const SPI_IOC_NR_MAX_SPEED_HZ: u8 = 4;
//! const SPI_IOC_NR_MODE32: u8 = 5;
//!
//! ioctl!(read get_mode_u8 with SPI_IOC_MAGIC, SPI_IOC_NR_MODE; u8); | random_line_split |
tararchiver.rs | use lzma::LzmaWriter as XzEncoder;
use bzip2::write::BzEncoder;
use flate2::write::GzEncoder;
use tar::Builder;
use std::io::{Write, Result};
use std::path::Path;
use std::convert::AsRef;
use std::fs::File;
use std::marker::PhantomData;
use archiver::FileArchiver;
use tarcompressor::HasTarCompressor;
use tarcompressor:... | }
fn add_directory<P: AsRef<Path>>(&mut self, dir_path: P, archive_dir_path: P) -> Result<()> {
self.inner.add_directory(dir_path, archive_dir_path)?;
Ok(())
}
fn finish(&mut self) -> Result<()> {
self.inner.finish()?;
... | random_line_split | |
tararchiver.rs | use lzma::LzmaWriter as XzEncoder;
use bzip2::write::BzEncoder;
use flate2::write::GzEncoder;
use tar::Builder;
use std::io::{Write, Result};
use std::path::Path;
use std::convert::AsRef;
use std::fs::File;
use std::marker::PhantomData;
use archiver::FileArchiver;
use tarcompressor::HasTarCompressor;
use tarcompressor:... | <P: AsRef<Path>>(&mut self, dir_path: P, archive_dir_path: P) -> Result<()> {
self.tar_builder.append_dir(archive_dir_path, dir_path)?;
Ok(())
}
fn finish(&mut self) -> Result<()> {
self.tar_builder.finish()?;
Ok(())
}
}
macro_rules! make_archiver {
($name:ident, $encod... | add_directory | identifier_name |
utils.rs | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
#[cfg(feature = "wasm")]
pub fn to_js_error<E: std::fmt::Debug>(e: E) -> wasm_bindgen::JsValue {
// TODO: The `JsValue::from_str()` constructs a `string` in JavaScript.
// We should switch to `js_sys::Error::new()`
// so that JavaScript's `try catch` can catch an `Error` object.
wasm_bindgen::JsValue:... | {
use ::sha2::{Digest, Sha256};
let mut hasher = Sha256::new();
hasher.update(bytes);
hasher.finalize().to_vec()
} | identifier_body |
utils.rs | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | {
first: bool,
waker: Option<Waker>,
}
impl OutOfOrderState {
pub fn new() -> Arc<Mutex<Self>> {
Arc::new(Mutex::new(OutOfOrderState {
first: true,
waker: None,
}))
}
}
struct OutOfOrderFuture<T, F: Fn() -> T> {
... | OutOfOrderState | identifier_name |
utils.rs | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
// Generated with:
// KEY=`mktemp` && CSR=`mktemp` &&
// openssl ecparam -out "$KEY" -name prime256v1 -genkey &&
// openssl req -new -sha256 -key "$KEY" -out "$CSR" -subj '/CN=example.org/O=Test/C=US' &&
// openssl x509 -req -days 90 -in "$CSR" -signkey "$KEY" -out - -extfile <(echo -e "1.3... | random_line_split | |
utils.rs | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | else {
if let Some(waker) = &state.waker {
println!("waking!");
waker.wake_by_ref();
}
Poll::Ready((self.value)())
}
}
}
}
| {
state.waker = Some(cx.waker().clone());
Poll::Pending
} | conditional_block |
main.rs | extern crate clap;
extern crate serde_json;
extern crate jmespath;
use std::rc::Rc;
use std::io::prelude::*;
use std::io;
use std::fs::File;
use std::process::exit;
use clap::{Arg, App};
use jmespath::Rcvar;
use jmespath::{Variable, compile};
macro_rules! die(
($msg:expr) => (
match writeln!(&mut ::std::... | (result: Rcvar, unquoted: bool) {
if unquoted && result.is_string() {
println!("{}", result.as_string().unwrap());
} else {
let mut out = io::stdout();
serde_json::to_writer_pretty(&mut out, &result)
.map(|_| out.write(&['\n' as u8]))
.map_err(|e| die!(format!("Erro... | show_result | identifier_name |
main.rs | extern crate clap;
extern crate serde_json;
extern crate jmespath;
use std::rc::Rc;
use std::io::prelude::*;
use std::io;
use std::fs::File;
use std::process::exit;
use clap::{Arg, App};
use jmespath::Rcvar;
use jmespath::{Variable, compile};
macro_rules! die(
($msg:expr) => (
match writeln!(&mut ::std::... | Some(f) => read_file("JSON", f),
None => {
let mut buffer = String::new();
match io::stdin().read_to_string(&mut buffer) {
Ok(_) => buffer,
Err(e) => die!(format!("Error reading JSON from stdin: {}", e)),
}
}
};
Variable... | random_line_split | |
main.rs | extern crate clap;
extern crate serde_json;
extern crate jmespath;
use std::rc::Rc;
use std::io::prelude::*;
use std::io;
use std::fs::File;
use std::process::exit;
use clap::{Arg, App};
use jmespath::Rcvar;
use jmespath::{Variable, compile};
macro_rules! die(
($msg:expr) => (
match writeln!(&mut ::std::... |
fn get_json(filename: Option<&str>) -> Variable {
let buffer = match filename {
Some(f) => read_file("JSON", f),
None => {
let mut buffer = String::new();
match io::stdin().read_to_string(&mut buffer) {
Ok(_) => buffer,
Err(e) => die!(format!... | {
match File::open(filename) {
Err(e) => die!(format!("Error opening {} file at {}: {}", label, filename, e)),
Ok(mut file) => {
let mut buffer = String::new();
file.read_to_string(&mut buffer)
.map_err(|e| die!(format!("Error reading {} from {}: {}", label, f... | identifier_body |
main.rs | extern crate rand;
use std::fmt::{self, Display};
const NUMBER_OF_DIGITS: usize = 4;
/// generates a random `NUMBER_OF_DIGITS`
fn generate_digits() -> Vec<u32> {
use rand;
let mut rng = rand::thread_rng();
rand::sample(&mut rng, (1u32..10), 4)
}
/// types of errors we can have when parsing a malformed ... | {
NotValidDigit,
ExpectedNumberOfDigits(usize),
NoDuplicates,
}
/// printable description for each `ParseError`
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ParseError::NotValidDigit => Display::fmt("only digits from 1 to 9... | ParseError | identifier_name |
main.rs | extern crate rand;
use std::fmt::{self, Display};
const NUMBER_OF_DIGITS: usize = 4;
/// generates a random `NUMBER_OF_DIGITS`
fn generate_digits() -> Vec<u32> {
use rand;
let mut rng = rand::thread_rng();
rand::sample(&mut rng, (1u32..10), 4)
}
/// types of errors we can have when parsing a malformed ... | (bulls, cows) => println!("bulls: {}, cows: {}", bulls, cows),
}
}
}
}
}
}
#[cfg(test)]
mod tests {
use super::ParseError;
/// test we generate `NUMBER_OF_DIGITS` unique digits between 1 and 9
#[test]
fn generate_digi... | {
let reader = std::io::stdin();
loop {
let given_digits = generate_digits();
println!("I have chosen my {} digits. Please guess what they are",
NUMBER_OF_DIGITS);
loop {
let mut guess_string = String::new();
let _ = reader.read_line(&mut guess_st... | identifier_body |
main.rs | extern crate rand;
| const NUMBER_OF_DIGITS: usize = 4;
/// generates a random `NUMBER_OF_DIGITS`
fn generate_digits() -> Vec<u32> {
use rand;
let mut rng = rand::thread_rng();
rand::sample(&mut rng, (1u32..10), 4)
}
/// types of errors we can have when parsing a malformed guess
enum ParseError {
NotValidDigit,
Expec... | use std::fmt::{self, Display};
| random_line_split |
run.rs | use std::collections::HashMap;
use std::vec::IntoIter;
use std::iter::Iterator;
use transit::StopTime;
#[derive(Debug, PartialEq)]
pub struct Run<'a> {
pub trip: String,
// TODO: StopTime is very verbose
// redundant info removed from StopTime (trip id, sequence) (maybe make a trait?)
pub sequence: Vec... | pickup_type: StopServiceType::RegularlyScheduled,
dropoff_type: StopServiceType::RegularlyScheduled,
timepoint: Timepoint::Exact,
shape_dist_traveled: None,
};
}
} | },
stop_id: format!("{}.{}", trip, sequence),
stop_sequence: sequence,
stop_headsign: None, | random_line_split |
run.rs | use std::collections::HashMap;
use std::vec::IntoIter;
use std::iter::Iterator;
use transit::StopTime;
#[derive(Debug, PartialEq)]
pub struct Run<'a> {
pub trip: String,
// TODO: StopTime is very verbose
// redundant info removed from StopTime (trip id, sequence) (maybe make a trait?)
pub sequence: Vec... |
}
#[cfg(test)]
mod test {
use super::*;
use transit::{StopServiceType, TimeOffset, Timepoint};
#[test]
fn test_form_runs_from_unsorted_sequences() {
let times = vec![
stop_time("A", 3, None, None),
stop_time("A", 2, None, None),
stop_time("B", 1, None, None... | {
self.runs.next()
} | identifier_body |
run.rs | use std::collections::HashMap;
use std::vec::IntoIter;
use std::iter::Iterator;
use transit::StopTime;
#[derive(Debug, PartialEq)]
pub struct Run<'a> {
pub trip: String,
// TODO: StopTime is very verbose
// redundant info removed from StopTime (trip id, sequence) (maybe make a trait?)
pub sequence: Vec... | <U: Iterator<Item = &'a StopTime>>(stop_times: U) -> RunIterator<'a> {
let mut run_groups = HashMap::<String, Run>::new();
// group StopTimes by trip
for stop_time in stop_times {
let run = run_groups.entry(stop_time.trip_id.clone()).or_insert(Run {
trip: stop_time.tr... | new | identifier_name |
array.rs | extern crate libc;
use self::libc::c_void;
use self::libc::memcpy;
use containers::{Ref, Vector};
use memory::Page;
use std::mem::{align_of, size_of};
use std::ops::{Deref, DerefMut, Index};
use std::ptr::{null_mut, write};
#[derive(Copy, Clone)]
pub struct Array<T: Copy> {
vector: Vector<T>,
length: usize,
}... |
}
}
}
impl<T: Copy> Index<usize> for Array<T> {
type Output = T;
fn index(&self, offset: usize) -> &Self::Output {
unsafe { &*self.vector.data.offset(offset as isize) }
}
}
impl<T: Copy> Deref for Array<T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe { ::std::... | {
let old_length = self.vector.length;
self.vector.length *= 2;
let old_data = self.vector.data;
self.vector.data =
(*_own_page).allocate_raw(self.vector.length * size, align_of::<T>()) as *mut T;
memcpy(
... | conditional_block |
array.rs | extern crate libc;
use self::libc::c_void;
use self::libc::memcpy;
use containers::{Ref, Vector};
use memory::Page;
use std::mem::{align_of, size_of};
use std::ops::{Deref, DerefMut, Index};
use std::ptr::{null_mut, write};
#[derive(Copy, Clone)]
pub struct Array<T: Copy> {
vector: Vector<T>,
length: usize,
}... | as *mut T;
} else {
let old_length = self.vector.length;
self.vector.length *= 2;
let old_data = self.vector.data;
self.vector.data =
(*_own_page).allocate_raw(self.vector.length * size, align_of::<T>()) ... | self.vector.length = capacity / size;
self.vector.data = (*exclusive_page)
.allocate_raw(self.vector.length * size, align_of::<T>()) | random_line_split |
array.rs | extern crate libc;
use self::libc::c_void;
use self::libc::memcpy;
use containers::{Ref, Vector};
use memory::Page;
use std::mem::{align_of, size_of};
use std::ops::{Deref, DerefMut, Index};
use std::ptr::{null_mut, write};
#[derive(Copy, Clone)]
pub struct Array<T: Copy> {
vector: Vector<T>,
length: usize,
}... | old_length * size,
);
let old_exclusive_page = Page::get(old_data as usize);
(*old_exclusive_page).forget();
}
}
}
}
impl<T: Copy> Index<usize> for Array<T> {
type Output = T;
fn index(&self, offset: usize) -> &Self::O... | {
let _own_page = Page::own(Ref::from(self as *mut Array<T>));
let size = size_of::<T>();
unsafe {
if self.vector.length == 0 {
let exclusive_page = (*_own_page).allocate_exclusive_page();
let capacity = (*exclusive_page).get_capacity::<T>();
... | identifier_body |
array.rs | extern crate libc;
use self::libc::c_void;
use self::libc::memcpy;
use containers::{Ref, Vector};
use memory::Page;
use std::mem::{align_of, size_of};
use std::ops::{Deref, DerefMut, Index};
use std::ptr::{null_mut, write};
#[derive(Copy, Clone)]
pub struct Array<T: Copy> {
vector: Vector<T>,
length: usize,
}... | (&self) -> *const T {
self.vector.data
}
pub fn get_length(&self) -> usize {
self.length
}
pub fn get_capacity(&self) -> usize {
self.vector.length
}
pub fn add(&mut self, item: T) {
if self.length == self.vector.length {
self.reallocate();
... | get_buffer | identifier_name |
rs_trigger.rs | #![allow(dead_code)]
extern crate rs_logic;
mod simple_logic;
use rs_logic::element::*;
use simple_logic::{init_or, init_not};
// X OR-NOT Y = NOT (X OR Y)
fn init_or_not() -> Element {
let mut or_not = Element::init("OR-NOT", 2, 1);
let or = or_not.push_element(init_or());
let not = or_not.push_element(... | rs.connect_wire(Wire::Output(o1, 0), Wire::Input(o2, 0));
rs.connect_wire(Wire::Output(o2, 0), Wire::Input(o1, 1));
// Q and NOT Q
rs.connect_wire(Wire::Output(o1, 0), Wire::OutputSelf(0));
rs.connect_wire(Wire::Output(o2, 0), Wire::OutputSelf(1));
rs
}
fn main() {
// RS initial output is (... | rs.connect_wire(Wire::InputSelf(0), Wire::Input(o1, 0));
rs.connect_wire(Wire::InputSelf(1), Wire::Input(o2, 1));
// feedback | random_line_split |
rs_trigger.rs | #![allow(dead_code)]
extern crate rs_logic;
mod simple_logic;
use rs_logic::element::*;
use simple_logic::{init_or, init_not};
// X OR-NOT Y = NOT (X OR Y)
fn init_or_not() -> Element {
let mut or_not = Element::init("OR-NOT", 2, 1);
let or = or_not.push_element(init_or());
let not = or_not.push_element(... | {
// RS initial output is (0, 0)
let mut rs = init_rs_trigger();
let input_data = vec![(1, 0), (1, 1), (0, 1)];
let output_data = vec![(0, 1), (0, 0), (1, 0)];
println!("RS trigger\n R S Q nQ | Q nQ");
// R S Q nQ
for (&(v1, v2), (r1, r2)) in input_data.iter().zip(output_d... | identifier_body | |
rs_trigger.rs | #![allow(dead_code)]
extern crate rs_logic;
mod simple_logic;
use rs_logic::element::*;
use simple_logic::{init_or, init_not};
// X OR-NOT Y = NOT (X OR Y)
fn init_or_not() -> Element {
let mut or_not = Element::init("OR-NOT", 2, 1);
let or = or_not.push_element(init_or());
let not = or_not.push_element(... | () {
// RS initial output is (0, 0)
let mut rs = init_rs_trigger();
let input_data = vec![(1, 0), (1, 1), (0, 1)];
let output_data = vec![(0, 1), (0, 0), (1, 0)];
println!("RS trigger\n R S Q nQ | Q nQ");
// R S Q nQ
for (&(v1, v2), (r1, r2)) in input_data.iter().zip(outpu... | main | identifier_name |
uint_macros.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... | #[experimental = "might need to return Result"]
impl FromStr for $T {
#[inline]
fn from_str(s: &str) -> Option<$T> {
strconv::from_str_common(s, 10u, false, false, false,
strconv::ExpNone, false, false)
}
}
#[experimental = "might need to return Result"]
impl FromSt... | }
| random_line_split |
overload-index-operator.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 ... | pairs: Vec<AssociationPair<K,V>> }
#[deriving(Clone)]
struct AssociationPair<K,V> {
key: K,
value: V
}
impl<K,V> AssociationList<K,V> {
fn push(&mut self, key: K, value: V) {
self.pairs.push(AssociationPair {key: key, value: value});
}
}
impl<K:Eq,V:Clone> Index<K,V> for AssociationList<K... |
struct AssociationList<K,V> { | random_line_split |
overload-index-operator.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 foo = ~"foo";
let bar = ~"bar";
let mut list = AssociationList {pairs: Vec::new()};
list.push(foo.clone(), 22);
list.push(bar.clone(), 44);
assert!(list[foo] == 22)
assert!(list[bar] == 44)
assert!(list[foo] == 22)
assert!(list[bar] == 44)
} | identifier_body | |
overload-index-operator.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 ... |
}
fail!("No value found for key: {:?}", index);
}
}
pub fn main() {
let foo = ~"foo";
let bar = ~"bar";
let mut list = AssociationList {pairs: Vec::new()};
list.push(foo.clone(), 22);
list.push(bar.clone(), 44);
assert!(list[foo] == 22)
assert!(list[bar] == 44)
a... | {
return pair.value.clone();
} | conditional_block |
overload-index-operator.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 ... | (&self, index: &K) -> V {
for pair in self.pairs.iter() {
if pair.key == *index {
return pair.value.clone();
}
}
fail!("No value found for key: {:?}", index);
}
}
pub fn main() {
let foo = ~"foo";
let bar = ~"bar";
let mut list = Associat... | index | identifier_name |
lib.rs | //! Rust bindings to `libui`.
//!
//! Main C source repository: https://github.com/andlabs/libui
//!
//! Copyright © 2016 Mozilla Foundation
#[macro_use]
extern crate bitflags;
extern crate libc;
extern crate ui_sys;
pub use controls::{Area, AreaDrawParams, AreaHandler, BoxControl, Button, Checkbox, ColorButton};
pub... | pub mod ffi_utils;
mod menus;
mod ui;
mod windows; | random_line_split | |
hello.rs | use std::env;
use std::ffi::OsStr;
use std::time::{Duration, UNIX_EPOCH};
use libc::ENOENT;
use fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyDirectory};
const TTL: Duration = Duration::from_secs(1); // 1 second
const HELLO_DIR_ATTR: FileAttr = FileAttr {
ino: 1,... | (&mut self, _req: &Request, ino: u64, reply: ReplyAttr) {
match ino {
1 => reply.attr(&TTL, &HELLO_DIR_ATTR),
2 => reply.attr(&TTL, &HELLO_TXT_ATTR),
_ => reply.error(ENOENT),
}
}
fn read(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, _size: u32,... | getattr | identifier_name |
hello.rs | use std::env;
use std::ffi::OsStr;
use std::time::{Duration, UNIX_EPOCH};
use libc::ENOENT;
use fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyDirectory};
const TTL: Duration = Duration::from_secs(1); // 1 second
const HELLO_DIR_ATTR: FileAttr = FileAttr {
ino: 1,... |
}
fn main() {
env_logger::init();
let mountpoint = env::args_os().nth(1).unwrap();
let options = ["-o", "ro", "-o", "fsname=hello"]
.iter()
.map(|o| o.as_ref())
.collect::<Vec<&OsStr>>();
fuse::mount(HelloFS, mountpoint, &options).unwrap();
}
| {
if ino != 1 {
reply.error(ENOENT);
return;
}
let entries = vec![
(1, FileType::Directory, "."),
(1, FileType::Directory, ".."),
(2, FileType::RegularFile, "hello.txt"),
];
for (i, entry) in entries.into_iter().enumer... | identifier_body |
hello.rs | use std::env;
use std::ffi::OsStr;
use std::time::{Duration, UNIX_EPOCH};
use libc::ENOENT;
use fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyDirectory};
const TTL: Duration = Duration::from_secs(1); // 1 second
const HELLO_DIR_ATTR: FileAttr = FileAttr {
ino: 1,... | reply.data(&HELLO_TXT_CONTENT.as_bytes()[offset as usize..]);
} else {
reply.error(ENOENT);
}
}
fn readdir(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, mut reply: ReplyDirectory) {
if ino!= 1 {
reply.error(ENOENT);
return;
... | random_line_split | |
result-types.rs | // cdb-only
// min-cdb-version: 10.0.18317.1001
// compile-flags:-g
// === CDB TESTS ==================================================================================
// cdb-command: g
// cdb-command: dx x,d
// cdb-check:x,d : Ok [Type: enum$<core::result::Result<i32,str> >]
// cdb-check: [...] __0 ... | assert_eq!(y.is_ok(), false);
zzz(); // #break.
}
fn zzz() { () } |
let y: Result<i32, &str> = Err("Some error message"); | random_line_split |
result-types.rs | // cdb-only
// min-cdb-version: 10.0.18317.1001
// compile-flags:-g
// === CDB TESTS ==================================================================================
// cdb-command: g
// cdb-command: dx x,d
// cdb-check:x,d : Ok [Type: enum$<core::result::Result<i32,str> >]
// cdb-check: [...] __0 ... | { () } | identifier_body | |
result-types.rs | // cdb-only
// min-cdb-version: 10.0.18317.1001
// compile-flags:-g
// === CDB TESTS ==================================================================================
// cdb-command: g
// cdb-command: dx x,d
// cdb-check:x,d : Ok [Type: enum$<core::result::Result<i32,str> >]
// cdb-check: [...] __0 ... | () { () }
| zzz | identifier_name |
enum_variants.rs | //! lint on enum variants that are prefixed or suffixed by the same characters
use clippy_utils::camel_case;
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
use clippy_utils::source::is_present_in_source;
use rustc_hir::{EnumDef, Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_s... | (
cx: &LateContext<'_>,
threshold: u64,
def: &EnumDef<'_>,
item_name: &str,
item_name_chars: usize,
span: Span,
) {
if (def.variants.len() as u64) < threshold {
return;
}
for var in def.variants {
let name = var.ident.name.as_str();
if partial_match(item_name,... | check_variant | identifier_name |
enum_variants.rs | //! lint on enum variants that are prefixed or suffixed by the same characters
use clippy_utils::camel_case;
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
use clippy_utils::source::is_present_in_source;
use rustc_hir::{EnumDef, Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_s... | }
impl LateLintPass<'_> for EnumVariantNames {
fn check_item_post(&mut self, _cx: &LateContext<'_>, _item: &Item<'_>) {
let last = self.modules.pop();
assert!(last.is_some());
}
#[allow(clippy::similar_names)]
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
l... | {
let mut s = String::new();
let mut up = true;
for c in item_name.chars() {
if c.is_uppercase() {
// we only turn snake case text into CamelCase
return item_name.to_string();
}
if c == '_' {
up = true;
continue;
}
if up... | identifier_body |
enum_variants.rs | //! lint on enum variants that are prefixed or suffixed by the same characters
use clippy_utils::camel_case;
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
use clippy_utils::source::is_present_in_source;
use rustc_hir::{EnumDef, Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_s... | Some(c) if is_word_beginning(c) => span_lint(
cx,
MODULE_NAME_REPETITIONS,
item.span,
"item name starts with its containing module's name",
... | if matching == nchars {
match item_camel.chars().nth(nchars) { | random_line_split |
shootout-meteor.rs | // Copyright 2013 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 ... |
// Makes every possible masks. masks[id][i] correspond to every
// possible masks for piece with identifier id with minimum coordinate
// (i/5, i%5).
fn make_masks() -> Vec<Vec<Vec<u64> > > {
let pieces = vec!(
vec!((0,0),(0,1),(0,2),(0,3),(1,3)),
vec!((0,0),(0,2),(0,3),(1,0),(1,1)),
vec!... | {
let mut m = 1 << (50 + id);
for &(y, x) in p.iter() {
let x = x + dx + (y + (dy % 2)) / 2;
if x < 0 || x > 4 {return None;}
let y = y + dy;
if y < 0 || y > 9 {return None;}
m |= 1 << (y * 5 + x);
}
Some(m)
} | identifier_body |
shootout-meteor.rs | // Copyright 2013 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 ... |
m |= 1 << (y * 5 + x);
}
Some(m)
}
// Makes every possible masks. masks[id][i] correspond to every
// possible masks for piece with identifier id with minimum coordinate
// (i/5, i%5).
fn make_masks() -> Vec<Vec<Vec<u64> > > {
let pieces = vec!(
vec!((0,0),(0,1),(0,2),(0,3),(1,3)),
... | {return None;} | conditional_block |
shootout-meteor.rs | // Copyright 2013 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 ... | }
// check if every coordinates can be covered and every piece can
// be used.
coverable!= (1 << 60) - 1
}
// Filter the masks that we can prove to result to unfeasible board.
fn filter_masks(masks: &[Vec<Vec<u64> > ]) -> Vec<Vec<Vec<u64> > > {
masks.iter().map(
|p| p.iter().map(
... | for &cur_m in pos_masks.get(i as uint).iter() {
if cur_m & board == 0 {coverable |= cur_m;}
}
}
if coverable & (1 << i) == 0 {return true;} | random_line_split |
shootout-meteor.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <'a, T> {
cur: &'a List<'a, T>
}
impl<'a, T> List<'a, T> {
fn iter(&'a self) -> ListIterator<'a, T> {
ListIterator{cur: self}
}
}
impl<'a, T> Iterator<&'a T> for ListIterator<'a, T> {
fn next(&mut self) -> Option<&'a T> {
match *self.cur {
Nil => None,
Cons(ref el... | ListIterator | identifier_name |
trait-inheritance-num2.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... | impl TypeExt for u16 {}
impl TypeExt for u32 {}
impl TypeExt for u64 {}
impl TypeExt for usize {}
impl TypeExt for i8 {}
impl TypeExt for i16 {}
impl TypeExt for i32 {}
impl TypeExt for i64 {}
impl TypeExt for isize {}
impl TypeExt for f32 {}
impl TypeExt for f64 {}
pub trait NumExt: TypeExt + PartialEq + PartialOr... | // A more complex example of numeric extensions
pub trait TypeExt {}
impl TypeExt for u8 {} | random_line_split |
trait-inheritance-num2.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... | {
test_float_ext(1f32);
} | identifier_body | |
trait-inheritance-num2.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... | () {
test_float_ext(1f32);
}
| main | identifier_name |
rational.rs | // http://rosettacode.org/wiki/Arithmetic/Rational
#![feature(zero_one)]
use std::num::{Zero, One};
use std::fmt;
use std::cmp::Ordering;
use std::ops::{Add, Mul, Neg, Sub, Div};
fn main() {
for p in perfect_numbers(1 << 19) {
println!("{} is perfect", p);
}
}
fn perfect_numbers(max: i64) -> Vec<i64... |
}
}
}
impl fmt::Debug for Frac {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match (self.num, self.den) {
(_, 1) | (0, 0) => write!(f, "{}", self.num),
(_, _) => write!(f, "{}/{}", self.num, self.den),
}
}
}
impl PartialEq for Frac {
fn eq(&s... | {
let gcd = gcd(self.num, self.den);
self.num /= gcd;
self.den /= gcd;
self
} | conditional_block |
rational.rs | // http://rosettacode.org/wiki/Arithmetic/Rational
#![feature(zero_one)]
use std::num::{Zero, One};
use std::fmt;
use std::cmp::Ordering;
use std::ops::{Add, Mul, Neg, Sub, Div};
fn main() {
for p in perfect_numbers(1 << 19) {
println!("{} is perfect", p);
}
}
fn perfect_numbers(max: i64) -> Vec<i64... |
}
impl Neg for Frac {
type Output = Frac;
fn neg(self) -> Frac {
Frac {
num: -self.num,
den: self.den,
}
}
}
impl Add for Frac {
type Output = Frac;
fn add(self, other: Frac) -> Frac {
let (a, b) = (self.reduce(), other.reduce());
let m = l... | {
(self.num * other.den).cmp(&(self.den * other.num))
} | identifier_body |
rational.rs | // http://rosettacode.org/wiki/Arithmetic/Rational
#![feature(zero_one)]
use std::num::{Zero, One};
use std::fmt;
use std::cmp::Ordering;
use std::ops::{Add, Mul, Neg, Sub, Div};
fn main() {
for p in perfect_numbers(1 << 19) {
println!("{} is perfect", p);
}
}
fn perfect_numbers(max: i64) -> Vec<i64... | (self.num * other.den).cmp(&(self.den * other.num))
}
}
impl Neg for Frac {
type Output = Frac;
fn neg(self) -> Frac {
Frac {
num: -self.num,
den: self.den,
}
}
}
impl Add for Frac {
type Output = Frac;
fn add(self, other: Frac) -> Frac {
... | }
impl Ord for Frac {
fn cmp(&self, other: &Frac) -> Ordering { | random_line_split |
rational.rs | // http://rosettacode.org/wiki/Arithmetic/Rational
#![feature(zero_one)]
use std::num::{Zero, One};
use std::fmt;
use std::cmp::Ordering;
use std::ops::{Add, Mul, Neg, Sub, Div};
fn main() {
for p in perfect_numbers(1 << 19) {
println!("{} is perfect", p);
}
}
fn perfect_numbers(max: i64) -> Vec<i64... | (self, other: Frac) -> Frac {
Frac::new_reduced(self.num * other.num, self.den * other.den)
}
}
impl Div for Frac {
type Output = Frac;
fn div(self, other: Frac) -> Frac {
Frac::new_reduced(self.num * other.den, self.den * other.num)
}
}
impl Zero for Frac {
fn zero() -> Frac {
... | mul | identifier_name |
reflect.rs | ::ty;
use util::ppaux::ty_to_str;
use std::libc::c_uint;
use std::option::None;
use std::vec;
use syntax::ast::def_id;
use syntax::ast;
use syntax::ast_map::path_name;
use syntax::parse::token::special_idents;
use middle::trans::type_::Type;
pub struct Reflector {
visitor_val: ValueRef,
visitor_methods: @~[@... | Store(bcx, len, GEPi(bcx, scratch.val, [ 0, 1 ]));
scratch.val
}
pub fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
let tr = type_of(self.bcx.ccx(), t);
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
... | Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0, 0 ])); | random_line_split |
reflect.rs | x, c_str, GEPi(bcx, scratch.val, [ 0, 0 ]));
Store(bcx, len, GEPi(bcx, scratch.val, [ 0, 1 ]));
scratch.val
}
pub fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
let tr = type_of(self.bcx.ccx(), t);
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
let a = m... | {
match sigil {
ast::OwnedSigil => 2u,
ast::ManagedSigil => 3u,
ast::BorrowedSigil => 4u,
}
} | identifier_body | |
reflect.rs | ty;
use util::ppaux::ty_to_str;
use std::libc::c_uint;
use std::option::None;
use std::vec;
use syntax::ast::def_id;
use syntax::ast;
use syntax::ast_map::path_name;
use syntax::parse::token::special_idents;
use middle::trans::type_::Type;
pub struct Reflector {
visitor_val: ValueRef,
visitor_methods: @~[@ty... | (&mut self,
t: ty::t,
vstore: ty::vstore)
-> (~str, ~[ValueRef]) {
match vstore {
ty::vstore_fixed(n) => {
let extra = vec::append(~[self.c_uint(n)],
... | vstore_name_and_extra | identifier_name |
hygienic-labels-in-let.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!(k, 1i);
let n = {
'x: for _ in range(0, 1) {
// ditto
run_once!(continue 'x);
i += 1;
}
i + 1
};
assert_eq!(n, 1i);
}
| {
let mut i = 0i;
let j = {
'x: loop {
// this 'x should refer to the outer loop, lexically
loop_x!(break 'x);
i += 1;
}
i + 1
};
assert_eq!(j, 1i);
let k = {
'x: for _ in range(0, 1) {
// ditto
loop_x!(bre... | identifier_body |
hygienic-labels-in-let.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 mut i = 0i;
let j = {
'x: loop {
// this 'x should refer to the outer loop, lexically
loop_x!(break 'x);
i += 1;
}
i + 1
};
assert_eq!(j, 1i);
let k = {
'x: for _ in range(0, 1) {
// ditto
loop_x!(... | main | identifier_name |
hygienic-labels-in-let.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... | // ditto
'x: for _ in range(0, 1) { $e }
}
}
pub fn main() {
let mut i = 0i;
let j = {
'x: loop {
// this 'x should refer to the outer loop, lexically
loop_x!(break 'x);
i += 1;
}
i + 1
};
assert_eq!(j, 1i);
let k = {... | }
macro_rules! run_once {
($e: expr) => { | random_line_split |
sem.rs | //! A rewrite of uapi/linux/sem.h
pub const SEM_UNDO: ::c_int = 0x1000; //TODO Check this to make sure it's a c_int
///Get sempid
pub const GETPID: ::c_int = 11;
///Get semval
pub const GETVAL: ::c_int = 12;
///Get all semvals
pub const GETALL: ::c_int = 13;
///Get semncnt
pub const GETNCNT: ::c_int = 14;
///Get ... | pub sem_ctime: ::__kernel_time_t,
pub sem_base: *mut ::sem,
pub sem_pending: *mut ::sem_queue,
pub sem_pending_last: *mut ::sem_queue,
pub undo: *mut ::sem_undo,
pub sem_nsems: ::c_ushort
} TODO: Complete enough to enable this */
///The semop system call takes an a... | pub sem_otime: ::__kernel_time_t,
| random_line_split |
sem.rs | //! A rewrite of uapi/linux/sem.h
pub const SEM_UNDO: ::c_int = 0x1000; //TODO Check this to make sure it's a c_int
///Get sempid
pub const GETPID: ::c_int = 11;
///Get semval
pub const GETVAL: ::c_int = 12;
///Get all semvals
pub const GETALL: ::c_int = 13;
///Get semncnt
pub const GETNCNT: ::c_int = 14;
///Get ... | {
///The semaphore's index in the array
pub sem_num: ::c_ushort,
///The semaphore operation
pub sem_op: ::c_short,
///The operation's flags
pub sem_flg: ::c_short
}
///The argument for semctl system calls
#[repr(C)]
pub enum semun {
val(::c_int),
//buf(*mut semid_ds),
... | sembuf | identifier_name |
uievent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::UIEventBin... |
pub fn Constructor(global: GlobalRef,
type_: DOMString,
init: &UIEventBinding::UIEventInit) -> Fallible<Root<UIEvent>> {
let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
let cancelable = if init.parent... | let ev = UIEvent::new_uninitialized(window);
ev.r().InitUIEvent(type_, can_bubble == EventBubbles::Bubbles,
cancelable == EventCancelable::Cancelable, view, detail);
ev
} | random_line_split |
uievent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::UIEventBin... | ;
let event = UIEvent::new(global.as_window(), type_,
bubbles, cancelable,
init.view.r(), init.detail);
Ok(event)
}
}
impl UIEventMethods for UIEvent {
// https://w3c.github.io/uievents/#widl-UIEvent-view
fn GetView(&self) ->... | {
EventCancelable::NotCancelable
} | conditional_block |
uievent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::UIEventBin... | (&self) -> i32 {
self.detail.get()
}
// https://w3c.github.io/uievents/#widl-UIEvent-initUIEvent
fn InitUIEvent(&self,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
view: Option<&Window>,
detail: ... | Detail | identifier_name |
board.rs | use std::fmt;
use std::ops::{Not,Mul};
use pattern::Pattern;
pub struct GameBoard {
field: [[State;3];3]
}
impl GameBoard {
pub fn new() -> GameBoard {
GameBoard {
field: [[State::Empty;3];3]
}
}
pub fn set_at(& mut self, who: State, at: (usize, usize)) {
self.fiel... | fmt.pad(out)
}
} | let out = match *self {
State::Empty => "_",
State::X => "X",
State::O => "O"
}; | random_line_split |
board.rs | use std::fmt;
use std::ops::{Not,Mul};
use pattern::Pattern;
pub struct GameBoard {
field: [[State;3];3]
}
impl GameBoard {
pub fn new() -> GameBoard {
GameBoard {
field: [[State::Empty;3];3]
}
}
pub fn set_at(& mut self, who: State, at: (usize, usize)) {
self.fiel... | (&self) -> usize {
let mut counter = 0usize;
for i in self.field.iter() {
for j in i.iter() {
match *j {
State::Empty => counter += 1,
_ => {},
}
}
}
counter
}
}
#[derive(Copy,Clone,Part... | empty_count | identifier_name |
board.rs | use std::fmt;
use std::ops::{Not,Mul};
use pattern::Pattern;
pub struct GameBoard {
field: [[State;3];3]
}
impl GameBoard {
pub fn new() -> GameBoard {
GameBoard {
field: [[State::Empty;3];3]
}
}
pub fn set_at(& mut self, who: State, at: (usize, usize)) {
self.fiel... |
}
impl Mul<usize> for State {
type Output = Pattern;
fn mul(self, rhs: usize) -> Pattern {
let mut p = Pattern::new();
p.set(self, rhs);
p
}
}
impl fmt::Debug for State {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let out = match *self {
Stat... | {
match self {
State::X => State::O,
State::O => State::X,
State::Empty => State::Empty
}
} | identifier_body |
ed25519.rs | use super::CryptoType;
use utils::crypto::ed25519::ED25519;
use errors::common::CommonError;
pub struct ED25519Signus {}
impl ED25519Signus {
pub fn new() -> ED25519Signus {
ED25519Signus {}
}
}
impl CryptoType for ED25519Signus {
fn encrypt(&self, private_key: &[u8], public_key: &[u8], doc: &[u... | (&self, sk: &[u8]) -> Result<Vec<u8>, CommonError> {
ED25519::sk_to_curve25519(sk)
}
} | signkey_to_private_key | identifier_name |
ed25519.rs | use super::CryptoType;
use utils::crypto::ed25519::ED25519;
use errors::common::CommonError;
pub struct ED25519Signus {} |
impl ED25519Signus {
pub fn new() -> ED25519Signus {
ED25519Signus {}
}
}
impl CryptoType for ED25519Signus {
fn encrypt(&self, private_key: &[u8], public_key: &[u8], doc: &[u8], nonce: &[u8]) -> Result<Vec<u8>, CommonError> {
ED25519::encrypt(private_key, public_key, doc, nonce)
}
... | random_line_split | |
ed25519.rs | use super::CryptoType;
use utils::crypto::ed25519::ED25519;
use errors::common::CommonError;
pub struct ED25519Signus {}
impl ED25519Signus {
pub fn new() -> ED25519Signus {
ED25519Signus {}
}
}
impl CryptoType for ED25519Signus {
fn encrypt(&self, private_key: &[u8], public_key: &[u8], doc: &[u... |
fn create_key_pair_for_signature(&self, seed: Option<&[u8]>) -> Result<(Vec<u8>, Vec<u8>), CommonError> {
ED25519::create_key_pair_for_signature(seed)
}
fn sign(&self, private_key: &[u8], doc: &[u8]) -> Result<Vec<u8>, CommonError> {
ED25519::sign(private_key, doc)
}
fn verify(&s... | {
ED25519::gen_nonce()
} | identifier_body |
pipe.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 ... | let fd = FileDesc::new(self.inner.writer.fd(), false);
match fd.write(&[0]) {
Ok(..) => Ok(()),
Err(..) if wouldblock() => Ok(()),
Err(e) => Err(e),
}
}
}
impl Clone for UnixAcceptor {
fn clone(&self) -> UnixAcceptor {
UnixAcceptor { inner: se... | pub fn close_accept(&mut self) -> IoResult<()> {
self.inner.closed.store(true, Ordering::SeqCst); | random_line_split |
pipe.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 ... | (addr: &CString,
timeout: Option<u64>) -> IoResult<UnixStream> {
connect(addr, libc::SOCK_STREAM, timeout).map(|inner| {
UnixStream::new(Arc::new(inner))
})
}
fn new(inner: Arc<Inner>) -> UnixStream {
UnixStream {
inner: inner,
read... | connect | identifier_name |
pipe.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 ... | else {0};
libc::recv(fd,
buf.as_mut_ptr() as *mut libc::c_void,
buf.len() as libc::size_t,
flags) as libc::c_int
};
read(fd, self.read_deadline, dolock, doread)
}
pub fn write(&mut self, buf: &[u8]) -> IoResult<()... | {c::MSG_DONTWAIT} | conditional_block |
main.rs | fn main() {
fn sum_vec (v: &Vec<i32>) -> i32 {
return v.iter().fold(0, |a, &b| a + b);
}
fn foo (v1: &Vec<i32>, v2: &Vec<i32>) -> i32 {
let s1 = sum_vec(v1);
let s2 = sum_vec(v2);
s1 + s2
}
fn | (v: &Vec<i32>) {
// v.push(5); // will cause error as not a mutable reference
}
let v = vec![];
foo1(&v);
let v1 = vec![1, 2, 3];
let v2 = vec![4, 5, 6];
let answer = foo(&v1, &v2);
println!("{}", answer);
// mutable reference
let mut x = 5;
{
let y = &mut x;
*y... | foo1 | identifier_name |
main.rs | fn main() {
fn sum_vec (v: &Vec<i32>) -> i32 {
return v.iter().fold(0, |a, &b| a + b);
}
fn foo (v1: &Vec<i32>, v2: &Vec<i32>) -> i32 {
let s1 = sum_vec(v1);
let s2 = sum_vec(v2);
s1 + s2
}
fn foo1 (v: &Vec<i32>) {
// v.push(5); // will cause error as not a mutable ... | *y += 1;
}
println!("{}", x);
// thinking in scope
let mut x2 = 5;
{
let y2 = &mut x2;
*y2 += 1;
// println!("{}", x); // not okay to be in the scope
}
println!("{}", x); // okay here as scope ended
} | random_line_split | |
main.rs | fn main() {
fn sum_vec (v: &Vec<i32>) -> i32 {
return v.iter().fold(0, |a, &b| a + b);
}
fn foo (v1: &Vec<i32>, v2: &Vec<i32>) -> i32 |
fn foo1 (v: &Vec<i32>) {
// v.push(5); // will cause error as not a mutable reference
}
let v = vec![];
foo1(&v);
let v1 = vec![1, 2, 3];
let v2 = vec![4, 5, 6];
let answer = foo(&v1, &v2);
println!("{}", answer);
// mutable reference
let mut x = 5;
{
let y = &mut ... | {
let s1 = sum_vec(v1);
let s2 = sum_vec(v2);
s1 + s2
} | identifier_body |
pause.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::WriteData;
use crate::storage::lock_manager::LockManager;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, WriteResult,
};
use crate::storage::txn::Result;
u... | (self, _snapshot: S, _context: WriteContext<'_, L>) -> Result<WriteResult> {
thread::sleep(Duration::from_millis(self.duration));
Ok(WriteResult {
ctx: self.ctx,
to_be_write: WriteData::default(),
rows: 0,
pr: ProcessResult::Res,
lock_info: Non... | process_write | identifier_name |
pause.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::WriteData;
use crate::storage::lock_manager::LockManager;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, WriteResult,
};
use crate::storage::txn::Result;
u... |
}
| {
thread::sleep(Duration::from_millis(self.duration));
Ok(WriteResult {
ctx: self.ctx,
to_be_write: WriteData::default(),
rows: 0,
pr: ProcessResult::Res,
lock_info: None,
lock_guards: vec![],
response_policy: ResponsePo... | identifier_body |
pause.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::WriteData;
use crate::storage::lock_manager::LockManager;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, WriteResult,
};
use crate::storage::txn::Result;
u... | Ok(WriteResult {
ctx: self.ctx,
to_be_write: WriteData::default(),
rows: 0,
pr: ProcessResult::Res,
lock_info: None,
lock_guards: vec![],
response_policy: ResponsePolicy::OnApplied,
})
}
} |
impl<S: Snapshot, L: LockManager> WriteCommand<S, L> for Pause {
fn process_write(self, _snapshot: S, _context: WriteContext<'_, L>) -> Result<WriteResult> {
thread::sleep(Duration::from_millis(self.duration)); | random_line_split |
probe_pins.rs | extern crate serial;
use std::env;
use std::thread;
use std::time::Duration;
use serial::prelude::*;
const SETTINGS: serial::PortSettings = serial::PortSettings {
baud_rate: serial::Baud9600,
char_size: serial::Bits8,
parity: serial::ParityNone,
stop_bits: serial::Stop1,
flow_contr... | try!(port.set_dtr(dtr));
}
println!("RTS={:5?} DTR={:5?} CTS={:5?} DSR={:5?} RI={:5?} CD={:?}",
rts,
dtr,
try!(port.read_cts()),
try!(port.read_dsr()),
try!(port.read_ri()),
try!(port.read_... | {
try!(port.configure(&SETTINGS));
try!(port.set_timeout(Duration::from_millis(100)));
try!(port.set_rts(false));
try!(port.set_dtr(false));
let mut rts = false;
let mut dtr = false;
let mut toggle = true;
loop {
thread::sleep(Duration::from_secs(1));
if toggle {
... | identifier_body |
probe_pins.rs | extern crate serial;
use std::env;
use std::thread;
use std::time::Duration;
use serial::prelude::*;
const SETTINGS: serial::PortSettings = serial::PortSettings {
baud_rate: serial::Baud9600,
char_size: serial::Bits8,
parity: serial::ParityNone,
stop_bits: serial::Stop1,
flow_contr... |
loop {
thread::sleep(Duration::from_secs(1));
if toggle {
rts =!rts;
try!(port.set_rts(rts));
}
else {
dtr =!dtr;
try!(port.set_dtr(dtr));
}
println!("RTS={:5?} DTR={:5?} CTS={:5?} DSR={:5?} RI={:5?} CD={:?}",
... | random_line_split | |
probe_pins.rs | extern crate serial;
use std::env;
use std::thread;
use std::time::Duration;
use serial::prelude::*;
const SETTINGS: serial::PortSettings = serial::PortSettings {
baud_rate: serial::Baud9600,
char_size: serial::Bits8,
parity: serial::ParityNone,
stop_bits: serial::Stop1,
flow_contr... | () {
for arg in env::args_os().skip(1) {
let mut port = serial::open(&arg).unwrap();
println!("opened device {:?}", arg);
probe_pins(&mut port).unwrap();
}
}
fn probe_pins<T: SerialPort>(port: &mut T) -> serial::Result<()> {
try!(port.configure(&SETTINGS));
try!(port.set_timeout... | main | identifier_name |
probe_pins.rs | extern crate serial;
use std::env;
use std::thread;
use std::time::Duration;
use serial::prelude::*;
const SETTINGS: serial::PortSettings = serial::PortSettings {
baud_rate: serial::Baud9600,
char_size: serial::Bits8,
parity: serial::ParityNone,
stop_bits: serial::Stop1,
flow_contr... |
else {
dtr =!dtr;
try!(port.set_dtr(dtr));
}
println!("RTS={:5?} DTR={:5?} CTS={:5?} DSR={:5?} RI={:5?} CD={:?}",
rts,
dtr,
try!(port.read_cts()),
try!(port.read_dsr()),
try!(port.read_... | {
rts = !rts;
try!(port.set_rts(rts));
} | conditional_block |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... | #[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBaseElem... | }
| random_line_split |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... | (localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
}
}
| new | identifier_name |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... |
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBaseEl... | {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLBaseElement, localName, prefix, document)
}
} | identifier_body |
simd-generics.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32);
// lame-o
let f32x4(x, y, z, w) = add(lr, lr);
assert_eq!(x, 2.0f32);
assert_eq!(y, 4.0f32);
assert_eq!(z, 6.0f32);
assert_eq!(w, 8.0f32);
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.