Skip to content

Instantly share code, notes, and snippets.

fn line_data<T>(line: &str) -> Vec<T> {
line.trim().split(' ').filter_map(|s| from_str::<T>(s)).collect()
}
error: failed to find an implementation of trait std::from_str::FromStr for T
fn line_data<T: std::from_str::FromStr>(line: &str) -> Vec<T> {
line.trim().split(' ').filter_map(|s| from_str::<T>(s)).collect()
}
fn parse_line(line: &str) -> LineType {
let first_character = line.chars().next();
match first_character {
Some(character) => match character {
'v' => {
let line_data = line_data(line);
fn line_data<T: std::from_str::FromStr>(line: &str) -> [T, ..3] {
let iter = line.trim().split(' ').filter_map(|s| from_str::<T>(s)).collect();
[iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap()]
}
line 3 : error: the type of this value must be known in this context
[iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap()]
def make_counter(starting_value):
count = starting_value
def counter():
nonlocal count
count += 1
return count
return counter
my_counter = make_counter(5)
my_counter()
using System;
using System.Text.RegularExpressions;
using System.Linq;
namespace fun {
class MainClass {
public static void Main (string[] args) {
var input = Console.ReadLine ();
Console.WriteLine (input.Contains ("+") ? Enumerable.Aggregate (from n in (new Regex (@"\d+|\.\d+|\d+\.").Matches (input).OfType<Match> ())select (n.ToString ()), (acc, x) => (float.Parse (acc) + float.Parse (x)).ToString()) : "");
}
E:\Github\Rusticle\src\types\utils.rs:139:14: 139:20 error: missing lifetime specifier [E0106]
E:\Github\Rusticle\src\types\utils.rs:139 static rs: [(&Regex,fn(&str) -> LineType), ..1] = [(&GeometericVertexRegex,vert_from_reg)];
^~~~~~
error: aborting due to previous error
[Finished in 0.3s]
fn line_type_from_reg<T>(line: &str, x:fn(&str) -> Option<T>) -> LineType {
match x(line) {
Some(y) => Failed,
None => Failed,
}
Failed
}
// Geometric vertex (v)
pub struct GeometericVertex {
pub x: f64,
pub y: f64,
pub z: f64,
}
fn new_make_geometric_vertex<Y, T: Index<uint,Y>>(d: T) -> GeometericVertex {
GeometericVertex { x: d[0], y: d[1], z: d[2] }
}
pub enum LineType {
GeometericVertexLine(GeometericVertex),
FaceLine(Face),
Failed,
Unused,
}
// Geometric vertex (v)
pub struct GeometericVertex {
pub x: f64,
pub enum VertexData {
GeoVert(GeometericVertex),
TexVert(TextureVertex),
VertNml(VertexNormals),
PmSVert(ParameterSpaceVertex),
}
impl fmt::Show for VertexData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {